catch_warnings blocks more robust

Explicitely calling clean_warning_registry before with block.
Fix for #3494 
I seem to have forgotten that it changed.