Added sync_error function and tests.