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/fa442b137764e0b6c0d991ba641e90c3217be1bf
https://github.com/bitcoin/bitcoin/pull/25781/commits/fa9bd7be472f49b15f5f87711094095954322635
Depends on D16008