moved Substring, renamed and added tests