Add regression test for #3823