refactor copy-diffs, more tests and fixes