Adopted tests to expose bug in IOHandler and fixed it.

Martin