Matrix distances and tests