Change tests to use tempfile