Changed classical HNF and tests to use row HNF and fixed several bugs