Fixed JSON-encoding issues with tests
Added the ability to disable JSON encoding