Finish replication routines implementation and tests