I think there's a bug here, Can you add a test for entitlement1 quantity 15, entitlement2 quantity 15 exist for the owner, and then the import brings in entitlement1 for 15 and entitlement3 for 15. (i.e. first entitlement is unchanged, second is a new entitlement but for same quantity) 

Looks like a potential problem, having a hard time seeing for sure but I think entitlement1 will match first even though it was already matched with something.