posix.lua: fix bug in posix.pipeline_iterator, where it always closed the pipe on first iteration
Simplify and fix pipeline_iterator, and add a test.