Regression test for #840. Closes #840.