#51 Added docAsUpsert methods and refactored original upsert. Added better tests.