HHH-7934 - Fix and test
(cherry picked from commit 69230d1ebd39b4cdc62f333e91b500ce648f63a1)