Commit 3a2f273b got the source and the target wrong when copying over the data. Fix that and add a regression test. Fixes #6111.