This changes background_cs from being a pointer to a reference to work
around a gcc false warning. Also, this makes the test easier to read.
Fixes https://github.com/bitcoin/bitcoin/issues/23101
Can be reviewed with --ignore-all-space.
This is a backport of core#23132