update linalg code and tests, fixes