Tests: Fix broken OS-X and Linux builds

* _dup2 is Windows only. Use dup2 instead
* Breakage was introduced in 76eecc6ce11d1bedee369859899901037dcd4cc2