Add tests for JSON serialization - reveals more bugs.