Performance fixes for tensorcontract!

Better recognition of matrix multiplication, previous implementation
failed because 1:2 == [1,2] is false