[PTFM-10999] Fix bug introduced in refactoring; add test for it