Added full test coverage. Fixes #1