HHH-7870 - Fix and test
(cherry picked from commit 0713cea18098e6fdec50dfffb09b324bbc900571)