added unit tests for json encoding