Minor refactorings for testability