Added tests using py.test.
Refactoring to make optimization a bit easier.
Support files for profiling and optimization.