Fix warnings and expected exceptions in tests.