fix for bug 87801 on CPAN

Hi, I've used the test case provided here by Thomas to create a test, and then I fixed the problem.
Please consider my pull request for review

https://rt.cpan.org/Ticket/Display.html?id=87801