Issue #6688 was already fixed by work on related issues #6552 and #6553. This adds a test that specifically reproduces the scenario mentioned in #6688. This fixes #6688