Fix assertions on raises exception type mismatch