The test was not very clear about what it does. Added comments to clarify what is done and why. Also fixed a typo.
Added test case that reproduces the problem and verifies that it is fixed.