Improved the haddock documentation and the tests