move helper method to spec file and refactor tests