Refactored repeated code in spec and improved legibility