Refactoring for testability. #2