This is the bug outlined in #974. This commit just adds a test which catches the problem, but does not fix it yet.