I don't think that's really a bug. The behavior you described only happens, when I attack an npc, which is attacking another npc. That means, that it will switch targets randomly during the time it's fighting. Imho, players shouldn't prioritized during a fight, it should remain random.