test for empty matrix + cleanup