Fix catching of warnings during testing.