Move implementation to replication layer and create unit-tests