Fix/sync

update and fix the sync function and fix it's tests