Fix error with traversing UserError handler stack

For some reason registering multiple UserError handlers when the inner one
returns null (i.e. to pass it further down the chain) didn't actually work
and both were invoked. Simplify the code and make it actually work.