Hello Mark, I was recently reminded of this bug by a new encounter; at last wrote a test for your proposed fix, and it appear to work as intended! I've committed it on your behalf in commit 485ac28235 on the core-updates branch.
Closing! Thank you for the clever hack :-) Maxim
