Patch + test for https://github.com/ocpsoft/rewrite/issues/117

As promised.