Fix relayErrorCallback and add tests.