refactorings for testability
tests