Handle expected AssertionError and AssumptionViolatedException.

Fixes #687. #121 is still fixed. (Pull request #323 was too rigid.)