The test helped me to find this bug.
After applying this PR, the test and code will work correctly.