more refactoring for tests