This was a really hard one to track down, but there is a test at least.
I've tried to keep the changes to a minimum. Pls. see dev/core#1108 (closed) for details.