Add a test for issue 5517

It appears the cause of #5517 was fixed in 0dc6c414, so adding a test so the issue can be closed.