Fix tests

I found some issues when trying to run the tests, and fixed them. Look at the commit message for description.