Add test for #647. Fails without fix.