add test for end after replace