Adds test for duplicate key insert
Fixes #333 by catching exceptions thrown when moving to oldDocuments
Merge pull request #342 from laserval/0.4.x

Fixes #333 (cherry-picked from master)