Add unittest for API function replace_termcodes