refactor, tests
add tests