Updated test function and logreg to use sparse matrices.