split out common unit test code