Added JSONCodecTest and fixed a bug exposed by the tests

Added JSONCodecTest and fixed a bug exposed by the tests.

Removed unnecessary utf8.