Fixed bugs in test.
Wrote a small python script to run tests.