HHH-8087 - Fix and test
(cherry picked from commit fa12131267440ac6ac3c9f8bc9f9cc8e9804642f)