Fix fd close problem for tests.