More extensive unit tests and javadoc for ToJson