Move common test code into setUp method to reduce duplication.