Reduced code and logic duplication in unit test.