Fix tests

This fixes multiple problems with the tests and allows running the tests with `python setup.py test`.