Add tests for JSON parsing of structs, fix some bugs