Refactor TestExpandString