Add unit tests

https://gist.github.com/kszeluk/77d715d590bdd356cd08