Refactoring for testing