Fix various exceptions in testing.