Add `replace` mode & Update tests