Add unit tests

Fixes issue #1, #2, #3