Fix bugs in ctm-train and ctm-test