refactoring for tests