Fix invocation error handling

Recently, the `WithErrorHandling` middleware was changed to not return a hash
of error information. This causes a bug since our consumer expects invocations
to return either a Hash or `nil`.

This patch updates the tests to assert that and fixes the bug.