More refactoring
Fix jsonschema mode some more
Add more tests