improved xSubString and its test