refactorings
add tests