Fix some tempfile issues in tests