test refactoring; extracing duplicate code