Have you tried this ? It is the correct approach, while I have not looked through your code in detail it appears correct.
var children = item.getChildren();for (var i = 0; i < children.length; i++) { alert("Child "+children.getName()}
BTW, just put the function name in the eventhandler call, test2 not test2(this)