Fix a failing test for a wrong exception

The fix mimics the code in the base class method.