more tests and fixes for JSON serialization