Get rid of some duplicated test code