Modify the way the filename was reset by the wrongfile tests

Uses a defer call now