Backport of core PR12477
https://github.com/bitcoin/bitcoin/pull/12477/files
The modifications in `checkqueue_tests.cpp` are already part of our
codebase.
The modifications of `test_bitcoin` are only required to clear memory
from `avalanche_tests` and `DoS_tests`. Avalanche tests use
`std::_unique_ptr`, making this fix useless, and so does DoS tests
since D2919.
Depends on D2919