Deduplicate test code