Added haddock comments for the main library

Patch by Jesper Lloyd
Extend test suite with quickcheck tests

Patch by Jesper Lloyd