[IMP]Sync,Test: Improved sync logic for record which is already there in database, do not create record which is matches reference_id in database, added a python test cases for sync_data