Fix unit tests

Fixes the issues that arose with the new aggregate_tests.py, which runs the unit tests in a single suite. This mostly involves moving tests' setup and teardown code into appropriate functions, so that it doesn't run on import. Also replaces test_extraneous_dependencies_attack.py, which previously tested something to do with delegations instead of dependencies, with a new version that functions as intended.