Refactored tests to remove duplication