Add test for #5783

I've added a testcase, as mentioned in #5783