#JC-1986:Fixed performance issue with custom tag replacing
Some refactoring and test seems be needed