diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@
 
 test/echo: test/Echo.hs
 	mkdir -p test/build
-	${GHC} test/build -O2 test/Echo.hs -o test/echo
+	${GHC} test/build test/Echo.hs -o test/echo
 
 .PHONY: test_run
 test_run: test/echo
diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -1,2 +1,4 @@
 import Distribution.Simple
-main = defaultMain
+
+main                         =  defaultMain
+
diff --git a/Text/ShellEscape/Bash.hs b/Text/ShellEscape/Bash.hs
--- a/Text/ShellEscape/Bash.hs
+++ b/Text/ShellEscape/Bash.hs
@@ -68,6 +68,8 @@
            | c <= 'Z'        =  Literal
            | c == '['        =  Quoted
            | c == '\\'       =  ANSIBackslash
+           | c <= ']'        =  Quoted
+           | c == '_'        =  Literal
            | c <= '`'        =  Quoted
            | c <= 'z'        =  Literal
            | c <= '~'        =  Quoted
diff --git a/Text/ShellEscape/Sh.hs b/Text/ShellEscape/Sh.hs
--- a/Text/ShellEscape/Sh.hs
+++ b/Text/ShellEscape/Sh.hs
@@ -39,7 +39,7 @@
  -}
 act :: EscapingMode -> (Char, EscapingMode) -> (Put.Put, EscapingMode)
 act Quote (c, Quote)         =  (Put.putChar c                 , Quote)
-act Quote (c, Literal)       =  (Put.putString ['\'', c]       , Literal)
+act Quote (c, Literal)       =  (Put.putChar c                 , Quote)
 act Quote (c, Backslash)     =  (Put.putString ['\'', '\\', c] , Literal)
 act Backslash (c, Backslash) =  (Put.putChar c                 , Literal)
 act Backslash (c, Quote)     =  (Put.putString ['\\', '\'', c] , Quote)
diff --git a/shell-escape.cabal b/shell-escape.cabal
--- a/shell-escape.cabal
+++ b/shell-escape.cabal
@@ -1,5 +1,5 @@
 name                          : shell-escape
-version                       : 0.1.1
+version                       : 0.1.2
 category                      : Text
 license                       : BSD3
 license-file                  : LICENSE
diff --git a/test/Echo.hs b/test/Echo.hs
--- a/test/Echo.hs
+++ b/test/Echo.hs
@@ -3,12 +3,13 @@
 
 import System.Environment
 import System.Process (runInteractiveProcess, waitForProcess, ProcessHandle)
-import System.IO (Handle, stderr, stdout, stdin)
-import Data.ByteString (ByteString, pack, hGetContents, hPutStrLn)
+import System.IO (Handle, stderr, stdout, stdin, hClose)
+import Data.ByteString (ByteString, pack, hGetContents)
 import qualified Data.ByteString
-import Data.ByteString.Char8 (unpack)
+import Data.ByteString.Char8 (unpack, hPutStrLn)
 import qualified Data.ByteString.Char8 as Char8
 import Data.Word
+import Control.Applicative
 import Control.Monad
 import qualified Text.Printf
 import Data.IORef
@@ -17,7 +18,7 @@
 import Test.QuickCheck
 import Test.QuickCheck.Monadic
 
-import Text.ShellEscape
+import Text.ShellEscape hiding (sh, bash)
 
 
 --  It is best to implement the echo test with `printf':
@@ -35,10 +36,9 @@
 printf escaped               =  do
   (i, o, e, p)              <-  shell escaped cmd
   exit                      <-  waitForProcess p
-  hGetContents o
+  hGetContents o <* mapM_ hClose [i, o, e]
  where
-  cmd                        =  "printf '%s' " ++ unpack raw
-  raw                        =  bytes escaped
+  cmd                        =  "printf '%s' " ++ unpack (bytes escaped)
 
 
 prop_echoBash               ::  ByteString -> Property
@@ -94,13 +94,12 @@
 
 instance Arbitrary ByteString where
   arbitrary                  =  do
-    bytes                   <-  arbitrary :: Gen [Word8]
-    NonEmpty bytes'         <-  arbitrary :: Gen (NonEmptyList Word8)
-    pack `fmap` elements [bytes', bytes', bytes, bytes', bytes']
-
-instance Arbitrary Word8 where
-  arbitrary                  =  fmap fromIntegral (choose ( 0x01 :: Int
-                                                          , 0xFF :: Int ))
+    bytes                   <-  arbitrary :: Gen [NonZero Word8]
+    NonEmpty bytes'         <-  arbitrary :: Gen (NonEmptyList (NonZero Word8))
+    pack `fmap` elements
+                (fmap unNonZero `fmap` [bytes', bytes', bytes, bytes', bytes'])
+   where
+    unNonZero (NonZero t) = t
 
 main                         =  do
   runSh                     <-  newIORef True
@@ -120,7 +119,7 @@
     _                       ->  error "Invalid arguments."
   tests                     <-  readIORef testsR
   let msg                    =  "Performing " ++ show tests ++ " tests."
-      qcArgs                 =  Args Nothing tests tests 32
+      qcArgs                 =  Args Nothing tests tests 32 False
       qc                     =  quickCheckWith qcArgs
   err "Tests are random ByteStrings, containing any byte but null."
   runSh ?> do
