TST: consolidate some test code