Restore tests (in progress)

Fixing the test suite so it passes again