Fixed bug and added unit tests (force the variables in mat files to be in column vectors).