Deduplicating some test code