Fix documentation, add tests

Fixes issue #1