Fixed bugs in repmat and typos in stack. Added some more unit tests.