Fix building errors on ghc < 7.8 and tests