fix duplicate objects after restoring data from localStorage

Attempt to fix #2134 (and possibly also #2091 and #1249).

~~This is not yet 100% finished, but can already be reviewed. Todos:~~

* [x] fix failing `restores from v2 JSON (modification)` test
* [x] add tests for `restores from v3 JSON`
* [x] undo v -> version refactoring