Refactoring to test