Fixes #2796, by adding a test for it.