Fixed fd leak in test code.