Better exception handling when creating nodes

test function shouldn't be called recursively since it will miss exceptions.