It seems preferable to assign globals to a class (in this case BlockManager), than to leave them dangling. This should clarify scope for code-readers, as well as clarifying unit test behaviour.
This is a partial backport of core#25781
https://github.com/bitcoin/bitcoin/pull/25781/commits/fa177d7b6b3ad008d442ff9622c9b30e68d6e388
Depends on D16007