Backport LHCbTest from master
Includes most notably !2260 (merged) (minimize new refs produced by validateWithRef) but also various follow-ups and other fixes.
Includes most notably !2260 (merged) (minimize new refs produced by validateWithRef) but also various follow-ups and other fixes.