Adding more json unit tests.
Added json unit tests and fixed a error handling bug.