HHH-7781 - Fix and test
(cherry picked from commit 03520b928f1c69dbf128d083f31b13dc03f7d314)