finished replace_pred and replace_succ and tests