Add test for #547
Fix #547