Fix consumer error handling.

And add some unit tests this time...