fix rsync code and tests