Move $titleForParse setting up earlier and use it in remaining transformMsg() call

Change-Id: I313316b928d6d6fe64398471f74c4a18ce3dbdc3