Bring unit tests up to date with latest changes to trimming and transactions. Fixes #590. Fixes #591