catch_warnings blocks more robust

Explicitely calling clean_warning_registry before with block.
Fix for #3494 
I think this case should work fine with `with ignore_warnings()` even with the `assert_warns` inside of it.