refactor state to JSON, added tests
limit coverage package, some formatting and review notes on other helpers
code refactoring