Set DYLD_LIBRARY_PATH when running tests on OS X.
Use 'close' rather than 'fdopendir' in the errno test.

'fdopendir' is not available on OS X.
Merge pull request #145 from yallop/macos-test-fixes

Macos test fixes