factor out common test code