diff --git a/Data/Vector/Binary.hs b/Data/Vector/Binary.hs
--- a/Data/Vector/Binary.hs
+++ b/Data/Vector/Binary.hs
@@ -93,7 +93,7 @@
     v <- return $ unsafePerformIO $ GM.unsafeNew n
     let go 0 = return ()
         go i = do x <- getA
-                  () <- return $ unsafePerformIO $ GM.unsafeWrite v (i-1) x
+                  () <- return $ unsafePerformIO $ GM.unsafeWrite v (n-i) x
                   go (i-1)
     () <- go n
     return $ unsafePerformIO $ G.unsafeFreeze v
diff --git a/test/Main.hs b/test/Main.hs
new file mode 100644
--- /dev/null
+++ b/test/Main.hs
@@ -0,0 +1,24 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+
+import Test.Tasty
+import Test.Tasty.QuickCheck
+import Data.Binary
+import Data.Vector.Binary
+import qualified Data.Vector as V
+import qualified Data.Vector.Generic as VG
+import qualified Data.Vector.Unboxed as VU
+import qualified Data.Vector.Storable as VS
+
+roundTrip :: forall v a. (Eq (v a), Binary (v a), VG.Vector v a)
+          => v a -> Property
+roundTrip v =
+    let v' = decode $ encode v :: v a
+    in property $ v' == v
+
+main = defaultMain $ testGroup "Vector Binary instances"
+    [ testProperty "Unboxed"  $ roundTrip $ VU.enumFromTo z 100
+    , testProperty "Storable" $ roundTrip $ VS.enumFromTo z 100
+    , testProperty "Boxed"    $ roundTrip $ V.enumFromTo  z 100
+    ]
+  where
+    z = 0 :: Int
diff --git a/vector-binary-instances.cabal b/vector-binary-instances.cabal
--- a/vector-binary-instances.cabal
+++ b/vector-binary-instances.cabal
@@ -1,5 +1,5 @@
 Name:                vector-binary-instances
-Version:             0.2.3.0
+Version:             0.2.3.1
 Synopsis:            Instances of Data.Binary and Data.Serialize for vector
 Description:
    Instances for Binary for the types defined in the vector package,
@@ -65,6 +65,16 @@
     criterion
   hs-source-dirs: benchmarks
 
+Test-Suite tests
+  Type:           exitcode-stdio-1.0
+  Main-is:        test/Main.hs
+  Build-depends:
+    base,
+    vector-binary-instances,
+    vector,
+    binary,
+    tasty,
+    tasty-quickcheck
 
 source-repository head
   type:     git
