Added test methods for sync module, fixed various bugs