Update API

Fix issue #7 as well as improve tests and update docs.