Fix defect in addNode where the index of the node wasn't being set. Added checks in tests for this