refactored some common test code