Remove test code duplication