Added more tests. Refactoring of json serialization.