Fix files that do work on import instead of only if __name__ == __main__

For this file the problem is a little different: the code you put inside `main()` is needed for the test class. The reason why it was put outside the test methods is because it's needed for multiple tests and we would waste computation by re-compiling for every test.

We should make this class inherit from `unittest.TestCase` and put the code inside a `setUp()` method (see [here](https://docs.python.org/2/library/unittest.html#unittest.TestCase.setUp)).