Fix #1732, with an unprincipaled hack.
Improve a test to cover #1732.