small refactors for testability