Factoring out common elements of tests