Deal with NaN and Inf in Hessian of dynamic model

Checks for these cases in stochastic_solvers.m to prevent cryptic crashes in dll-files later on
Merge pull request #742 from JohannesPfeifer/second_order_hessian_problems

Deal with NaN and Inf in Hessian of dynamic model