Unittests

Kinda work in progress, I'll just open a pull request for now and keep updating it while I'm working on it. :-) 
(see http://scottchacon.com/2011/08/31/github-flow.html work flow)