Fix errors and add test to cabal file