Backport of core PR15352.
The most interesting part here is the commit 5fd73c8:
Avoid repeated log messages in tests by connecting to signal handlers (ThreadSafeMessageBox, etc.) only once
which will prevent from flooding the test_bitcoin output with a ton of
misleading wallet error messages (since D5004).
I extended the scope to a couple more tests that were printing a message
due to no assertion being run.
Note to reviewers: the changes to src/test/blockencodings_tests.cpp
does not apply to us (see D5049).