First: txnmall.sh is the start of an integration test for wallet handling of mutated (malleable) transaction handling.
Second is a one-line change to IsConfirmed that adds a condition when considering change outputs : only consider them confirmed if they are in the memory pool (inspired by a comment sipa made yesterday).
This makes getbalance, getbalance '*', and listunspent all agree when run on the txnmall.sh test wallets. Before this fix, those three would return three different results.
Before: listunspent: one 49BTC output getbalance: 96 BTC (change counted twice) getbalance '*': 46 BTC (spends counted twice)
After: all agree, 49 BTC available to spend.