test and fix endless loop when pasting issue; fixes #785