Add test for errors thrown in andThen.

Test confirming that errors thrown in `andThen` properly fail a test.

Closes #5366.