type_id makes sense.

RE: int(row.get('contactTypeID') or 0) - TypeID will never be null -> It will either be 2 for corp, 16159 for alliance or variable depending on Pilot type.

Regarding the tests - The XML is it faked? A couple of the entities on there are listed as alliance or corp but are really characters?