Added tests for sync tree and fixed found bugs.