Refactored (and reactivated) a lot of unit tests. Fixes #2.