Fix duplicate code at head of test files