sum and diag work
added more tests, caught and fixed constraint bug