test: open stdout fd in write-only mode

Fixes #771.