More Code Reorganisation

Finished moving the appropriate functions out of `transaction.py`,
namely into `script.py` and `backend.py`. Some of those functions were
temporarily in `util.py`.

Minor changes to test suite to make this work.