Refactor parsing method. Write a test to verify JSON parsing. Fix constraints