Add tests for #5997