Extracted expect_io_write() helper function
Extracted expect_io_read() helper function