Fixed an incorrect check in commit traverser.

Also added a new unit test to cover the case that would have previously been affected.

Fixes #389