Replace KeyError by the IODeviceError
Update tests for the new error type