we (the readers) were told and shown that he is/can be a jerk, but then soon after we see that he does things that completely contradict the "jerk" mold.
Some people really are jerks in some circumstances, and genuinely heroic in other circumstances.
For that matter, I've known people who would get all worked up, loudly, over extremely minor things, but in any real emergency would become calm reliable rocks that could be leaned on.
Humans are weird, and complicated.