Yes, this looks indeed like a bug.
Thank you very much for creating this great code snippet and @Dominika_Basaj thanks a lot for reporting this issue.
I’ll create an issue on GitHub and will link it here.
EDIT: Issue created here 8