Extracted some common test code