I've improved the test a little bit and it showed me, that the original patch doesn't cover all common cases. I'll send a new version of the patch (test included) once I find out how to resolve the issue.
If you want to post the new issue, perhaps I can take a look at it as well.
- Chris