add tests, refactor for testability