HHH-7437 - Fix and test
(cherry picked from commit bcf73bd32c2af2dc2dcb6e160f4b39e23c532253)