Fix a bug transpose_dense()

The function was implemented incorrectly if the number of rows and columns is
different. A test for this was added that fails.

The assert statement was fixed as well as the loop, now the added test passes.

Fixes #304.
Merge pull request #306 from certik/transpose_fix

Fix a bug in transpose_dense()