Added the logic and tests for merging comments