implement capture_io, adding a test