Refactoring for tests