Add unit tests

Units test for all classes were added.
![coverage](https://f.cloud.github.com/assets/4586875/2363761/6883f85e-a654-11e3-8bbd-021b59b87432.png)
Some classes received minor edits to be better testable.