Adds unit tests for all situations

I had some problem with the mocking class, but this post
explained to me why it wasn't working:
http://alexmarandon.com/articles/python_mock_gotchas/
Reformats code so pep8 is happy