Add checks in test after code review
Remove error in hessian if gradient is constant