Deduplicate test setup code