Refactoring to fix test