diff --git a/crypto-pubkey-openssh.cabal b/crypto-pubkey-openssh.cabal
--- a/crypto-pubkey-openssh.cabal
+++ b/crypto-pubkey-openssh.cabal
@@ -1,7 +1,7 @@
 Name:               crypto-pubkey-openssh
-Version:            0.2.0
-Synopsis:           OpenSSH public keys parser
-Description:        OpenSSH public keys parser
+Version:            0.2.1
+Synopsis:           OpenSSH keys decoder/encoder
+Description:        OpenSSH keys decoder/encoder
 License:            MIT
 License-file:       LICENSE
 Copyright:          Fedor Gogolev <knsd@knsd.net>
@@ -18,7 +18,7 @@
 Tested-with:        GHC == 7.6.*
 
 Flag OpenSsh
-  Description:      Test with openssh-keygen
+  Description:      Test with ssh-keygen
   Default:          False
 
 Library
@@ -30,7 +30,7 @@
                   , base64-bytestring          == 1.0.*
                   , cereal                     == 0.3.*
                   , attoparsec                 == 0.10.*
-                  , crypto-pubkey-types        == 0.3.*
+                  , crypto-pubkey-types        == 0.4.*
                   , pem                        == 0.1.*
                   , asn1-data                  == 0.7.*
 
@@ -53,7 +53,7 @@
                   , base64-bytestring          == 1.0.*
                   , cereal                     == 0.3.*
                   , attoparsec                 == 0.10.*
-                  , crypto-pubkey-types        == 0.3.*
+                  , crypto-pubkey-types        == 0.4.*
                   , pem                        == 0.1.*
                   , asn1-data                  == 0.7.*
 
@@ -63,6 +63,7 @@
                   , temporary                  == 1.1.*
                   , process                    == 1.1.*
                   , filepath                   == 1.3.*
+                  , deepseq                    == 1.3.*
 
 Source-repository head
   Type:             git
diff --git a/src/Crypto/PubKey/OpenSsh/Encode.hs b/src/Crypto/PubKey/OpenSsh/Encode.hs
--- a/src/Crypto/PubKey/OpenSsh/Encode.hs
+++ b/src/Crypto/PubKey/OpenSsh/Encode.hs
@@ -22,12 +22,13 @@
                                     OpenSshPrivateKey(..))
 
 fixZeroByte :: [Word8] -> [Word8]
+fixZeroByte [] = []
 fixZeroByte bs = if testBit (head bs) msb then 0:bs else bs
   where
     msb = 7
 
 expandInteger :: Integer -> [Word8]
-expandInteger n = reverse $ unfoldr expand $ n
+expandInteger n = reverse $ unfoldr expand n
   where
     expand :: Integer -> Maybe (Word8, Integer)
     expand e | e == 0    = Nothing
diff --git a/tests/Tests.hs b/tests/Tests.hs
--- a/tests/Tests.hs
+++ b/tests/Tests.hs
@@ -1,75 +1,18 @@
 {-# LANGUAGE CPP #-}
-{-# LANGUAGE TypeSynonymInstances #-}
 
 module Main where
 
-import Data.Monoid ((<>))
-import System.FilePath.Posix ((</>), (<.>))
-import System.Process (runCommand, waitForProcess)
-import System.IO.Temp (withSystemTempDirectory)
-import qualified Data.ByteString.Char8 as SB
-
-import Test.Framework (Test, defaultMain, testGroup)
-import Test.Framework.Providers.QuickCheck2 (testProperty)
-import Test.QuickCheck (Property, Arbitrary(..), elements, suchThat)
-import Test.QuickCheck.Monadic (monadicIO, run, assert)
-
-import Crypto.PubKey.OpenSsh.Types (OpenSshKeyType(..), OpenSshPublicKey(..),
-                                    OpenSshPrivateKey(..))
-import Crypto.PubKey.OpenSsh (encodePublic, decodePublic,
-                              encodePrivate, decodePrivate)
-
-type StrictByteString = SB.ByteString
-type PrivateKey = StrictByteString
-type PublicKey = StrictByteString
-
-instance Arbitrary OpenSshKeyType where
-    arbitrary = elements [OpenSshKeyTypeRsa, OpenSshKeyTypeDsa]
-
-openSshKeys :: OpenSshKeyType -> IO (PrivateKey, PublicKey)
-openSshKeys t = withSystemTempDirectory base $ \dir -> do
-    let path = dir </> typ
-    let run = "ssh-keygen -t " <> typ <> " -N \"\" -f " <> path
-    waitForProcess =<< runCommand run
-    priv <- SB.readFile $ path
-    pub <- fmap SB.init $ SB.readFile $ path <.> "pub"
-    return (priv, pub)
-  where
-    base = "crypto-pubkey-openssh-tests"
-    typ = case t of
-        OpenSshKeyTypeRsa -> "rsa"
-        OpenSshKeyTypeDsa -> "dsa"
+import Test.Framework (defaultMain)
 
-testWithOpenSsh :: OpenSshKeyType -> Property
-testWithOpenSsh t = monadicIO $ do
-    (priv, pub) <- run $ openSshKeys t
-    assert $ checkPublic (decodePublic pub) pub
-    assert $ checkPrivate (decodePrivate priv) priv
-  where
-    checkPublic = case t of
-        OpenSshKeyTypeRsa -> \r b -> case r of
-            Right k@(OpenSshPublicKeyRsa _ _) ->
-                encodePublic k == b
-            _                                 -> False
-        OpenSshKeyTypeDsa -> \r b -> case r of
-            Right k@(OpenSshPublicKeyDsa _ _) ->
-                encodePublic k == b
-            _                                 -> False
-    checkPrivate = case t of
-        OpenSshKeyTypeRsa -> \r b -> case r of
-            Right k@(OpenSshPrivateKeyRsa _) ->
-                encodePrivate k == b
-            _                                 -> False
-        OpenSshKeyTypeDsa -> \r b -> case r of
-            Right k@(OpenSshPrivateKeyDsa _ _) ->
-                encodePrivate k == b
-            _                                 -> False
+import qualified Crypto.PubKey.OpenSsh.Encode.Tests
+import qualified Crypto.PubKey.OpenSsh.Decode.Tests
+import qualified SshKeygen
 
 main :: IO ()
 main = defaultMain
-    [
+    [ Crypto.PubKey.OpenSsh.Encode.Tests.tests
+    , Crypto.PubKey.OpenSsh.Decode.Tests.tests
 #ifdef OPENSSH
-      testGroup "ssh-keygen" [ testProperty "decode/encode" $ testWithOpenSsh
-                             ]
+    , SshKeygen.tests
 #endif
     ]
