Clean up hessian.m

Fix description of algorithm and document the function better. Also removes manual increasing of loop variable and moves computation of temporary variable not depending on loop variables outside of the loop as it needs to be computed only once.
Added unitary test for hessian routine.
osr: add option opt_algo. #779
Merge remote-tracking branch 'remotes/personal/gsa' into gsa