diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -31,6 +31,7 @@
 
 [lz4]: http://code.google.com/p/lz4
 [issue tracker]: https://github.com/mwotton/lz4hs/issues
+[continuous integration]: https://travis-ci.org/mwotton/lz4hs
 [gh]: https://github.com/mwotton/lz4hs
 [bb]: http://bitbucket.org/mwotton/lz4hs
 [Hackage]: http://hackage.haskell.org/package/lz4c
diff --git a/lz4.cabal b/lz4.cabal
--- a/lz4.cabal
+++ b/lz4.cabal
@@ -1,5 +1,5 @@
 name:                lz4
-version:             0.2
+version:             0.2.1
 synopsis:            LZ4 compression for ByteStrings
 description:
   High level bindings to the LZ4 compression library.
@@ -49,7 +49,8 @@
   build-depends:
     base >= 3 && < 5,
     bytestring,
-    hspec, QuickCheck,
+    hspec >= 1.3, QuickCheck,
+    HUnit,
     lz4
 
   ghc-options:      -fno-cse -fwarn-tabs
diff --git a/src/Codec/Compression/LZ4.hsc b/src/Codec/Compression/LZ4.hsc
--- a/src/Codec/Compression/LZ4.hsc
+++ b/src/Codec/Compression/LZ4.hsc
@@ -1,4 +1,6 @@
 {-# LANGUAGE CPP #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+
 -- |
 -- Module      : Codec.Compression.LZ4
 -- Copyright   : (c) Mark Wotton, Austin Seipp 2012
@@ -122,8 +124,10 @@
   where go (l, str) =
           U.unsafeUseAsCString str $ \cstr -> do
             out <- SI.createAndTrim l $ \p -> do
-              r <- fromIntegral <$> c_LZ4_uncompress cstr p (fromIntegral l)
-              return $! if (r <= 0) then 0 else r
+              r :: Int <- fromIntegral <$> c_LZ4_uncompress cstr p (fromIntegral l)
+              --- NOTE: r is the count of bytes c_LZ4_uncompress read from input buffer,
+              --- and NOT the count of bytes used in result buffer
+              return $! if (r <= 0) then 0 else l
             return $! if (S.null out) then Nothing else (Just out)
 {-# INLINEABLE decompress #-}
 
@@ -167,11 +171,9 @@
 
 -- Gets a ByteString and it's length from the compressed format.
 unformat :: Get (Int, S.ByteString)
-unformat = do
-  c <-  fromIntegral <$> getWord32le
-  l  <- fromIntegral <$> getWord32le
-  bs <- getByteString l
-  return (c, bs)
+unformat =  (,) <$> (fromIntegral <$> getWord32le)
+                <*> (fromIntegral <$> getWord32le >>= getByteString)
+
 
 
 --------------------------------------------------------------------------------
diff --git a/tests/Properties.hs b/tests/Properties.hs
--- a/tests/Properties.hs
+++ b/tests/Properties.hs
@@ -1,10 +1,13 @@
-{-# LANGUAGE ViewPatterns #-}
+{-# LANGUAGE ViewPatterns, OverloadedStrings #-}
 module Main (main) where
 import Test.Hspec
 import Test.Hspec.QuickCheck
+import Test.Hspec.HUnit
+import Test.HUnit
 import Test.QuickCheck
+import Control.Applicative
 
-import qualified Data.ByteString as S
+import qualified Data.ByteString.Char8 as S
 import Codec.Compression.LZ4
 
 main :: IO ()
@@ -22,6 +25,13 @@
     prop "is pure (normal)"     $ prop_decompress_pure compress decompress
     prop "is pure (high)"       $ prop_decompress_pure compressHC decompress
     prop "is pure (ultra)"      $ prop_decompress_pure compressPlusHC decompressPlusHC
+  describe "regression test" $ do
+    let input = "\STXd\STX\SOH\NUL\NUL\NUL\NUL\NUL\NUL\NUL\vexample.com\SOH\NUL\NUL\NUL\NUL\NUL\NUL\NUL\ETX\NUL\NUL\NUL\NUL\NUL\NUL\NUL\SI\NUL\NUL\NUL\NUL\NUL\NUL\NUL\tWhirlpool\NUL\NUL\NUL\NUL\NUL\NUL\NUL\vexample.com\NUL\STXf\SOH\SOH\NUL\NUL\NUL\NUL\NUL\NUL\NUL\ffacebook.com\SOH\NUL\NUL\NUL\NUL\NUL\NUL\NUL\SOH\NUL\NUL\NUL\NUL\NUL\NUL\NUL\b\NUL\NUL\NUL\NUL\NUL\NUL\NUL\EOTSHA1\NUL\NUL\NUL\NUL\NUL\NUL\NUL\ffacebook.com\NUL\SOH\NUL\NUL\NUL\NUL\NUL\NUL\NUL\tgmail.com\SOH\NUL\NUL\NUL\NUL\NUL\NUL"
+    it "can compress an oddly full-of-NULLs string"
+      (TestCase $ assertEqual "odd string" (Just input) (return input >>=
+                                                         compress >>= 
+                                                         decompress))
+      
 
 prop_compress_pure comp decomp (S.pack -> xs) =
   (comp xs) == (comp xs)
