Incorrect jacobian using ForwardDiff and sparse functions

This seems to be another example of the problem fixed by #481, like this post.