6635 test sync framework

@johnfriz  Could you review the changes? Most of it are tests, small bug fix in the sync client itself.