Fix test and handle close correctly
Respect cancellation for all IO operations