I'll try to fix this bug and create some tests, then I send a format-patch here. I'll need to do that anyway.