It is simpler using this?
var thisLayer = activeDocument.activeLayer;
// create new layerset if doesn't exist
if (activeDocument.layerSets.length == 0) activeDocument.layerSets.add();
// return to previous selected layer
activeDocument.activeLayer = thisLayer;
// move layer to the referenced layerSets[0] but the id of this element could be any number
activeDocument.activeLayer.move (activeDocument.layerSets[0], ElementPlacement.PLACEATEND);
So the solution is to create first a script for(var a in activeDocument.layerSets) to reference your chosen layerSet by id and if exists it gives you the index.