Fix returning of JSON parse errors and add more tests for that