Thanks for reporting the problem. I see a bug in Emacs in this area, which I fixed by installing the attached patch into master on Savannah. Can you please give this patch a try in your environment (doesn't have to be emacs -Q)? Thanks.