cleanup and added test for getChildrenByIndex