I'm attaching a reference patch that fixes the issue for me. However, I'm sorry but I don't have the time to work on adding a test for it. -- Best regards, Michał Górny