Merge "Fix bugs found during cts test." into tm-dev