Factored out the common test code