HHH-7948 - Fix and test
(cherry picked from commit d702dfbc8c2bbd22863d853ceb3640dd794764c2)