Dear Stanislav, thanks for reporting this, I confirm the bug.
I shared a note on the SO entry asking for a patch: since the solution is mostly written, it would help if a patch could be sent to this mailing list directly. See https://orgmode.org/worg/org-contribute.html on how to contribute. Thanks! -- Bastien