AI helper functions: code cleanup, first pass

These function libraries are still work in progress and change
frequently, so the code cleanup is mostly just to make sure the syntax
is consistent with that used in the Micro AIs.  Changes or improvements
to the algorithms might be made at a later time.
Fix a typo
battle_calcs.lua: avoid using formula= in SUFs

It’s slow for finding units with moves or attacks left. The alternative
method of getting all units and then looping over the table with a
condition is much faster.
ai_helper.lua: avoid using table.remove

It’s slow. The inverse logic using table.insert is much faster,
especially for large tables.
Protect Unit MAI test scenario: use fight_on_without_leader=yes

So that the scenario continues even if the side 2 leader is killed.