Added test for get_gradient_and_hessian and modified get_gradient_and_hessian for more secured implementation