createCostFn accepts/returns a column vector

Also fixed the logit function gradient.
fixed gradient test