Added a test for this case. Re #6621.