Refactored unit tests to remove repetition.