Matrix function contracts, equals contract, and fixed other contracts th...

...at were failing tests.
@isupeene 
Can remove `row_size` here, I think.