Updated/refactored upperNZ/lowerNZ, fixed sparsity.py tests, #544