diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -23,9 +23,15 @@
 -- | file: readme-samples/example0.hs
 {-# LANGUAGE DataKinds #-}
 {-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE OverloadedStrings #-}
 
 import Data.Maybe
 import Data.ByteString (ByteString)
+import Data.Text (Text)
+import qualified Data.Text.IO as T
+import qualified Data.ByteString as BS
+import qualified Data.ByteString.Base16 as B16
+import Data.Base16.Types (assertBase16, extractBase16)
 import Asterix.Coding
 import Asterix.Generated as Gen
 
@@ -33,6 +39,14 @@
 assert True = pure ()
 assert False = error "Assertion error"
 
+-- | Convert bytestring to hex representation.
+hexlify :: BS.ByteString -> Text
+hexlify = extractBase16 . B16.encodeBase16
+
+-- | Convert hex representation back to a bytestring.
+unhexlify :: Text -> BS.ByteString
+unhexlify = B16.decodeBase16' . assertBase16
+
 -- Select particular asterix categories and editions
 type Cat034 = Gen.Cat_034_1_29
 type Cat048 = Gen.Cat_048_1_32
@@ -131,7 +145,7 @@
         ssr = asString $ getItem @"MODE3A" i070
 
 expected :: ByteString
-expected = fromJust $ unhexlify "220007c0010201220008d00102020030000c9801020a0020000fff220008d001020220"
+expected = unhexlify "220007c0010201220008d00102020030000c9801020a0020000fff220008d001020220"
 
 main :: IO ()
 main = do
@@ -139,7 +153,7 @@
     print ("sending message: " <> show txMessage)
     let datablocks = fmap encode txMessage
         tx = toByteString $ mconcat datablocks
-    putStrLn ("bytes on the wire: " <> hexlify tx)
+    T.putStrLn ("bytes on the wire: " <> hexlify tx)
     assert (tx == expected)
 
     -- decode bytes back to message, expect the same message
@@ -353,22 +367,34 @@
 ```haskell
 -- | file: readme-samples/catflt.hs
 {-# LANGUAGE DataKinds #-}
+{-# LANGUAGE OverloadedStrings #-}
 
 import Control.Monad
-import Data.Maybe
 import Data.ByteString (ByteString)
+import Data.Text (Text)
+import qualified Data.ByteString.Base16 as B16
+import Data.Base16.Types (assertBase16, extractBase16)
+import qualified Data.Text.IO as T
 import Asterix.Coding
 
+-- | Convert bytestring to hex representation.
+hexlify :: ByteString -> Text
+hexlify = extractBase16 . B16.encodeBase16
+
+-- | Convert hex representation back to a bytestring.
+unhexlify :: Text -> ByteString
+unhexlify = B16.decodeBase16' . assertBase16
+
 -- UDP rx test function
 receiveFromUdp :: IO ByteString
-receiveFromUdp = pure $ fromJust $ unhexlify $ join
+receiveFromUdp = pure $ unhexlify $ mconcat
     [ "01000401" -- cat1 datablock
     , "02000402" -- cat2 datablock
     ]
 
 -- UDP tx test function
 sendToUdp :: SBuilder -> IO ()
-sendToUdp = putStrLn . hexlify . toByteString
+sendToUdp = T.putStrLn . hexlify . toByteString
 
 main :: IO ()
 main = do
@@ -392,11 +418,15 @@
 -- | file: readme-samples/rewrite-sacsic.hs
 {-# LANGUAGE DataKinds #-}
 {-# LANGUAGE MonoLocalBinds #-}
+{-# LANGUAGE OverloadedStrings #-}
 
 import GHC.TypeLits
-import Data.Maybe
 import Data.Either
 import Data.ByteString (ByteString)
+import qualified Data.ByteString.Base16 as B16
+import Data.Base16.Types (assertBase16, extractBase16)
+import Data.Text (Text)
+import qualified Data.Text.IO as T
 
 import Asterix.Coding
 import Asterix.Generated as Gen
@@ -409,6 +439,14 @@
 -- All of the following types have the same item "010"
 type TSacSic = SameType '[ Cat048 ~> "010", Cat062 ~> "010", Cat063 ~> "010"]
 
+-- | Convert bytestring to hex representation.
+hexlify :: ByteString -> Text
+hexlify = extractBase16 . B16.encodeBase16
+
+-- | Convert hex representation back to a bytestring.
+unhexlify :: Text -> ByteString
+unhexlify = B16.decodeBase16' . assertBase16
+
 handleDatablock :: forall cat.
     ( Schema (RecordOf cat) VRecord
     , SetItem "010" (Record (RecordOf cat)) (NonSpare TSacSic)
@@ -453,7 +491,7 @@
 
 -- Dummy tx function
 txBytesToTheNetwork :: SBuilder -> IO ()
-txBytesToTheNetwork = putStrLn . hexlify . toByteString
+txBytesToTheNetwork = T.putStrLn . hexlify . toByteString
 
 main :: IO ()
 main = do
@@ -461,11 +499,11 @@
     let newSacSic :: NonSpare TSacSic
         newSacSic = group (1 *: 2 *: nil)
         sOutput = rewriteSacSic newSacSic sInput
-        expected = fromJust $ unhexlify
+        expected = unhexlify
             "300011900102000000009001020000000030000a90010200000000"
     txBytesToTheNetwork sOutput
     case expected == toByteString sOutput of
-        True -> print "OK"
+        True -> putStrLn "OK"
         False -> error "unexpected output"
 ```
 
@@ -541,15 +579,24 @@
 ```haskell
 -- | file: readme-samples/ref.hs
 {-# LANGUAGE DataKinds #-}
+{-# LANGUAGE OverloadedStrings #-}
 
 import Data.Either
 import Data.Maybe
+import Data.Text (Text)
+import qualified Data.ByteString as BS
+import qualified Data.ByteString.Base16 as B16
+import Data.Base16.Types (assertBase16)
 import Asterix.Coding
 import Asterix.Generated as Gen
 
 type Spec = Gen.Cat_062_1_20
 type Ref  = Gen.Ref_062_1_3
 
+-- | Convert hex representation back to a bytestring.
+unhexlify :: Text -> BS.ByteString
+unhexlify = B16.decodeBase16' . assertBase16
+
 assert :: Bool -> IO ()
 assert True = pure ()
 assert False = error "Assertion error"
@@ -578,7 +625,7 @@
 main = do
     let s = unparse @SBuilder db
         bs = toByteString s
-        expected = fromJust $ unhexlify
+        expected = unhexlify
             "3e001b8101010104010211c8010000000000020000010000028000"
     assert (bs == expected)
 
@@ -631,17 +678,24 @@
 -- | file: readme-samples/generic-names.hs
 {-# LANGUAGE DataKinds #-}
 {-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE OverloadedStrings #-}
 
 import Control.Monad
 import Data.Word
-import Data.Maybe
 import Data.Either
 import Data.Map as Map
+import Data.Text (Text)
 import Data.ByteString (ByteString)
+import qualified Data.ByteString.Base16 as B16
+import Data.Base16.Types (assertBase16)
 
 import Asterix.Coding
 import Asterix.Generated as Gen
 
+-- | Convert hex representation back to a bytestring.
+unhexlify :: Text -> ByteString
+unhexlify = B16.decodeBase16' . assertBase16
+
 specs :: Map Word8 VRecord
 specs = Map.fromList
     [ (48, schema @(RecordOf Cat_048_1_31) Proxy)
@@ -652,7 +706,7 @@
 
 -- some test input bytes
 s :: ByteString
-s = mconcat $ fmap (fromJust . unhexlify)
+s = mconcat $ fmap unhexlify
     [ "3e00a5254327d835a95a0d0a2baf256af940e8a8d0caa1a594e1e525f2e32bc0448b"
     , "0e34c0b6211b5847038319d1b88d714b990a6e061589a414209d2e1d00ba5602248e"
     , "64092c2a0410138b2c030621c2043080fe06182ee40d2fa51078192cce70e9af5435"
@@ -676,7 +730,7 @@
     forM_ rawDatablocks $ \db -> do
         let cat = rawDatablockCategory db
         case Map.lookup cat specs of
-            Nothing -> print ("unsupported category", cat)
+            Nothing -> print ("unsupported category" :: String, cat)
             Just (GRecord sch) -> do
                 let act = parseRecords (GRecord sch)
                     records = fromRight (error "unexpected")
@@ -691,11 +745,24 @@
 -- | file: readme-samples/generic-zero.hs
 {-# LANGUAGE DataKinds #-}
 {-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE OverloadedStrings #-}
 
-import Data.Maybe
+import Data.Text (Text)
+import qualified Data.Text.IO as T
+import qualified Data.ByteString as BS
+import qualified Data.ByteString.Base16 as B16
+import Data.Base16.Types (assertBase16, extractBase16)
 import Asterix.Coding
 import Asterix.Generated as Gen
 
+-- | Convert bytestring to hex representation.
+hexlify :: BS.ByteString -> Text
+hexlify = extractBase16 . B16.encodeBase16
+
+-- | Convert hex representation back to a bytestring.
+unhexlify :: Text -> BS.ByteString
+unhexlify = B16.decodeBase16' . assertBase16
+
 assert :: Bool -> IO ()
 assert True = pure ()
 assert False = error "Assertion error"
@@ -757,10 +824,10 @@
 
 main :: IO ()
 main = do
-    let expected = fromJust $ unhexlify
+    let expected = unhexlify
             "3e0038bfe9bd5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
         result = toByteString $ unparse @SBuilder db
-    putStrLn $ hexlify result
+    T.putStrLn $ hexlify result
     assert (result == expected)
 ```
 
@@ -880,12 +947,24 @@
 ```haskell
 -- | file: readme-samples/construct1.hs
 {-# LANGUAGE DataKinds #-}
-
-import Data.Maybe
+{-# LANGUAGE OverloadedStrings #-}
 
+import Data.Text (Text)
+import qualified Data.Text.IO as T
+import qualified Data.ByteString as BS
+import qualified Data.ByteString.Base16 as B16
+import Data.Base16.Types (assertBase16, extractBase16)
 import Asterix.Coding
 import Asterix.Generated as Gen
 
+-- | Convert bytestring to hex representation.
+hexlify :: BS.ByteString -> Text
+hexlify = extractBase16 . B16.encodeBase16
+
+-- | Convert hex representation back to a bytestring.
+unhexlify :: Text -> BS.ByteString
+unhexlify = B16.decodeBase16' . assertBase16
+
 assert :: Bool -> IO ()
 assert True = pure ()
 assert False = error "Assertion error"
@@ -909,10 +988,10 @@
 main = do
     let sb :: SBuilder = unparse db062
         result = toByteString sb
-        expected = fromJust $ unhexlify
+        expected = unhexlify
             "3e0015911101100102003db34024304f820820029c"
     assert (result == expected)
-    putStrLn $ hexlify result
+    T.putStrLn $ hexlify result
 ```
 
 ### Parsing
@@ -1032,17 +1111,26 @@
 ```haskell
 -- | file: readme-samples/dep-content.hs
 {-# LANGUAGE DataKinds #-}
+{-# LANGUAGE OverloadedStrings #-}
 
 import Control.Monad
 import Data.Maybe
 import Data.Either
 import Data.ByteString (ByteString)
+import Data.Text (Text)
+import qualified Data.ByteString as BS
+import qualified Data.ByteString.Base16 as B16
+import Data.Base16.Types (assertBase16)
 
 import Asterix.Coding
 import Asterix.Generated as Gen
 
 type Spec = Gen.Cat_062_1_20
 
+-- | Convert hex representation back to a bytestring.
+unhexlify :: Text -> BS.ByteString
+unhexlify = B16.decodeBase16' . assertBase16
+
 assert :: Bool -> IO ()
 assert True = pure ()
 assert False = error "Assertion error"
@@ -1099,7 +1187,7 @@
 db0 = datablock (rec0 *: rec1 *: rec2 *: rec3 *: nil)
 
 expected :: ByteString
-expected = fromJust $ unhexlify "3e0017011010000101101000010110104ccd0110108320"
+expected = unhexlify "3e0017011010000101101000010110104ccd0110108320"
 
 main :: IO ()
 main = do
@@ -1127,10 +1215,10 @@
                     1 -> unQuantity $ asQuantity @"Mach" @('Just 1) iIAS2
                     _ -> error "unexpected value"
 
-            print ("--- record", cnt, "---")
-            print ("I062/380/IAS/IM raw value:", asUint @Integer iIM)
-            print ("I062/380/IAS/IAS raw value:", asUint @Integer iIAS2)
-            print ("converted value", value)
+            print ("--- record" :: String, cnt, "---" :: String)
+            print ("I062/380/IAS/IM raw value:" :: String, asUint @Integer iIM)
+            print ("I062/380/IAS/IAS raw value:" :: String, asUint @Integer iIAS2)
+            print ("converted value" :: String, value)
 ```
 
 #### Handling **variation dependency**
@@ -1141,16 +1229,26 @@
 ```haskell
 -- | file: readme-samples/dep-variation.hs
 {-# LANGUAGE DataKinds #-}
+{-# LANGUAGE OverloadedStrings #-}
 
 import Control.Monad
 import Data.Maybe
 import Data.Either
 import Data.ByteString (ByteString)
+import Data.Text (Text)
+import qualified Data.ByteString as BS
+import qualified Data.ByteString.Base16 as B16
+import Data.Base16.Types (assertBase16)
+
 import Asterix.Coding
 import Asterix.Generated as Gen
 
 type Spec = Gen.Cat_004_1_13 -- Cat 004, edition 1.13
 
+-- | Convert hex representation back to a bytestring.
+unhexlify :: Text -> BS.ByteString
+unhexlify = B16.decodeBase16' . assertBase16
+
 -- Item 'I004/120/CC/CPC' depends on I004/000 and I004/120/CC/TID values
 -- Default case is: element3, raw, but there are many other cases.
 -- See asterix specification for details.
@@ -1209,7 +1307,7 @@
 db0 = datablock (rec0 *: rec1 *: rec2 *: nil)
 
 expected :: ByteString
-expected = fromJust $ unhexlify "040012412000400041200540104120094028"
+expected = unhexlify "040012412000400041200540104120094028"
 
 main :: IO ()
 main = do
@@ -1225,7 +1323,7 @@
             records = either (const (error "unexpected")) (fmap Record)
                 (parse @StrictParsing act (getRawRecords db))
         forM_ (zip [0::Int ..] records) $ \(cnt, rec) -> do
-            print ("--- record", cnt, "---")
+            print ("--- record" :: String, cnt, "---" :: String)
             let i000 = fromJust $ getItem @"000" rec
                 i120 = fromJust $ getItem @"120" rec
                 iCC = fromJust $ getItem @"CC" $ getVariation i120
@@ -1413,6 +1511,7 @@
 
 import Control.Monad
 import Data.Maybe
+import qualified Data.Text.IO as T
 import Asterix.Coding
 import Asterix.Generated as Gen
 
@@ -1439,13 +1538,13 @@
 main = do
     -- extract regular item 010
     let i010Regular = fromJust $ getItem @"010" rec1
-    putStrLn $ debugBits $ unparse @Bits i010Regular
+    T.putStrLn $ debugBits $ unparse @Bits i010Regular
 
     -- extract RFS items 010, expecting 2 such items
     let i010Rfs = getRfsItem @"010" rec1
     assert (length i010Rfs == 2)
     forM_ i010Rfs $ \i -> do
-        putStrLn $ debugBits $ unparse @Bits i
+        T.putStrLn $ debugBits $ unparse @Bits i
 
     -- but item '000' is not present in RFS
     assert (null $ getRfsItem @"000" rec1)
@@ -1492,10 +1591,15 @@
 ```haskell
 -- | file: readme-samples/parsing-partial-mode.hs
 {-# LANGUAGE DataKinds #-}
+{-# LANGUAGE OverloadedStrings #-}
 
 import Data.Maybe
 import Data.Either
 import Data.ByteString (ByteString)
+import Data.Text (Text)
+import qualified Data.ByteString as BS
+import qualified Data.ByteString.Base16 as B16
+import Data.Base16.Types (assertBase16)
 
 import Asterix.Coding
 import Asterix.Generated as Gen
@@ -1503,6 +1607,10 @@
 type SpecOld = Gen.Cat_063_1_6
 type SpecNew = Gen.Cat_063_1_7
 
+-- | Convert hex representation back to a bytestring.
+unhexlify :: Text -> BS.ByteString
+unhexlify = B16.decodeBase16' . assertBase16
+
 assert :: Bool -> IO ()
 assert True = pure ()
 assert False = error "Assertion error"
@@ -1523,7 +1631,7 @@
 
 main :: IO ()
 main = do
-    let expected = fromJust $ unhexlify "c8010203030506"
+    let expected = unhexlify "c8010203030506"
     assert (bs == expected)
 
     -- We should be able to parse the record, using the new spec
diff --git a/libasterix.cabal b/libasterix.cabal
--- a/libasterix.cabal
+++ b/libasterix.cabal
@@ -1,6 +1,6 @@
 cabal-version:      3.0
 name:               libasterix
-version:            0.17.2
+version:            0.18.0
 synopsis:           Asterix data processing library
 description:
     This library provides features to process asterix data format, including
@@ -58,7 +58,6 @@
     build-depends:
         , text ^>= 2.1.3
         , bytestring ^>= 0.12.2.0
-        , base16-bytestring ^>= 1.0.2.0
         , transformers ^>= 0.6.1.1
         , containers ^>= 0.7
 
@@ -77,6 +76,8 @@
     main-is:          Main.hs
     build-depends:
         , libasterix
+        , text ^>= 2.1.3
+        , base16 ^>= 1.0
         , bytestring
         , tasty
         , tasty-quickcheck
diff --git a/src/Asterix/BitString.hs b/src/Asterix/BitString.hs
--- a/src/Asterix/BitString.hs
+++ b/src/Asterix/BitString.hs
@@ -3,7 +3,8 @@
 --
 -- Bits and bytes manipulation module.
 
-{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE LambdaCase        #-}
+{-# LANGUAGE OverloadedStrings #-}
 
 module Asterix.BitString where
 
@@ -12,14 +13,14 @@
 import           Data.Bool
 import           Data.ByteString         (ByteString)
 import qualified Data.ByteString         as BS
-import qualified Data.ByteString.Base16  as B16
 import           Data.ByteString.Builder as BSB
-import qualified Data.ByteString.Char8   as BS8
 import qualified Data.ByteString.Lazy    as BSL
 import           Data.Coerce
 import qualified Data.List               as L
 import           Data.List.NonEmpty      (NonEmpty (..), uncons)
 import           Data.Maybe
+import           Data.Text               (Text)
+import qualified Data.Text               as T
 import           Data.Word
 import           GHC.Stack
 
@@ -88,14 +89,6 @@
     toByteString :: t -> ByteString
     fromByteString :: ByteString -> t
 
--- | Convert bytestring to hex representation.
-hexlify :: BS.ByteString -> String
-hexlify = BS8.unpack . B16.encode
-
--- | Convert hex representation back to a bytestring.
-unhexlify :: String -> Maybe BS.ByteString
-unhexlify = either (const Nothing) Just . B16.decode . BS8.pack
-
 -- | Helper function for expression evaluation.
 withAssumption :: HasCallStack => Bool -> a -> a
 withAssumption False _  =
@@ -269,9 +262,19 @@
 word8ToSBuilder :: Word8 -> SBuilder
 word8ToSBuilder = SBuilder 1 . BSB.word8
 
+-- | Convert 'ByteString' to 'SBuilder'.
+byteStringToSBuilder :: ByteString -> SBuilder
+byteStringToSBuilder bs = SBuilder (BS.length bs) (byteString bs)
+
+-- | Convert 'LazyByteString' to 'SBuilder'.
+lazyByteStringToSBuilder :: BSL.ByteString -> SBuilder
+lazyByteStringToSBuilder bs = SBuilder
+    (fromIntegral $ BSL.length bs)
+    (lazyByteString bs)
+
 -- | Show value as binary string.
-debugBits :: ToBits t => t -> String
-debugBits val = mconcat $ L.intersperse " " (goOctet <$> octets)
+debugBits :: ToBits t => t -> Text
+debugBits val = mconcat $ L.intersperse " " (T.pack . goOctet <$> octets)
   where
     Bits bs o n' = toBits val
     n = numBitsToInt n'
@@ -279,7 +282,11 @@
     (m, b) = requiredBytes o8 n
     k = bool m (pred m) (b == 0)
     a = numBytes o
+
+    octets :: [Int]
     octets = [a .. (a+k)]
+
+    goOctet :: Int -> String
     goOctet ix =
         let w = BS.index bs ix
         in do
diff --git a/test/Common.hs b/test/Common.hs
--- a/test/Common.hs
+++ b/test/Common.hs
@@ -2,15 +2,26 @@
 
 module Common where
 
+import           Data.Base16.Types      (assertBase16, extractBase16)
 import           Data.Bool
+import qualified Data.ByteString        as BS
+import qualified Data.ByteString.Base16 as B16
 import           Data.Char
-import qualified Data.List.NonEmpty as NE
-import           Data.Maybe
+import qualified Data.List.NonEmpty     as NE
+import           Data.Text              (Text)
 import           Test.Tasty.HUnit
 
 import           Asterix.Base
 import           Asterix.Coding
 
+-- | Convert bytestring to hex representation.
+hexlify :: BS.ByteString -> Text
+hexlify = extractBase16 . B16.encodeBase16
+
+-- | Convert hex representation to bytestring.
+unhexlify :: Text -> BS.ByteString
+unhexlify = B16.decodeBase16' . assertBase16
+
 approximately :: (Ord a, Fractional a) => a -> a -> a -> Bool
 approximately err a b = abs (b - a) / a < err
 
@@ -22,9 +33,9 @@
 assertUint :: Unparsing Bits t => Integer -> t -> Assertion
 assertUint n obj = assertEqual "uint" n (asUint obj)
 
-assertUnparse :: Unparsing Bits t => String -> t -> Assertion
+assertUnparse :: Unparsing Bits t => Text -> t -> Assertion
 assertUnparse s obj = assertEqual "unparse"
-        (debugBits @Bits $ byteStringToBits (fromJust $ unhexlify s))
+        (debugBits @Bits $ byteStringToBits (unhexlify s))
         (debugBits @Bits $ unparse obj)
 
 assertOne :: [a] -> IO a
@@ -32,8 +43,8 @@
 assertOne _   = assertFailure "expecting list of length 1"
 
 data StResult
-    = Bin String
-    | Hex String
+    = Bin Text
+    | Hex Text
 
 checkBits :: Unparsing Bits a => String -> a -> StResult -> Assertion
 checkBits name x = \case
diff --git a/test/TestAsterix.hs b/test/TestAsterix.hs
--- a/test/TestAsterix.hs
+++ b/test/TestAsterix.hs
@@ -2,8 +2,9 @@
 
 -- Remark: Keep asterix test scenarios synchronized between implementations.
 
-{-# LANGUAGE DataKinds  #-}
-{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE DataKinds         #-}
+{-# LANGUAGE LambdaCase        #-}
+{-# LANGUAGE OverloadedStrings #-}
 
 module TestAsterix
 ( tests
@@ -323,7 +324,7 @@
 testExtended1 :: Assertion
 testExtended1 = do
     let act = parseNonSpare (schema @(RecordOf Cat_000_1_0 ~> "053") Proxy)
-        bs = fromJust $ unhexlify "80"
+        bs = unhexlify "80"
         env = Env parsingStore bs
         result = runParsing act env 0
     (_obj, o) <- either (assertFailure . show) pure result
@@ -374,7 +375,7 @@
 testExtended2 :: Assertion
 testExtended2 = do
     let act = parseNonSpare (schema @(RecordOf Cat_000_1_0 ~> "054") Proxy)
-        bs = fromJust $ unhexlify "80"
+        bs = unhexlify "80"
         env = Env parsingStore bs
         result = runParsing act env 0
     (_obj, o) <- either (assertFailure . show) pure result
@@ -447,7 +448,7 @@
     -- Create extended sample with last FX bit set to '1' (wrong).
     -- Parsing shall fail in this case.
     let act = parseNonSpare (schema @(RecordOf Cat_000_1_0 ~> "053") Proxy)
-        bs = fromJust $ unhexlify "010101"
+        bs = unhexlify "010101"
         env = Env parsingStore bs
         result = runParsing act env 0
     assertEqual "failure" True (isLeft result)
@@ -497,7 +498,7 @@
 
 testExplicit0 :: Assertion
 testExplicit0 = do
-    let bs = fromJust $ unhexlify "00"
+    let bs = unhexlify "00"
         act = parseNonSpare (schema @(RecordOf Cat_000_1_0 ~> "071") Proxy)
         result = parse @StrictParsing act bs
     assertEqual "result" True (isLeft result)
@@ -505,10 +506,10 @@
 testExplicit1 :: Assertion
 testExplicit1 = do
     let obj :: NonSpare (RecordOf Cat_000_1_0 ~> "071")
-        obj = explicit $ fromJust $ unhexlify "010203"
+        obj = explicit $ unhexlify "010203"
     assertUnparse "04010203" obj
     assertEqual "data"
-        (byteStringToBits (fromJust $ unhexlify "010203"))
+        (byteStringToBits (unhexlify "010203"))
         (getExplicitData $ getVariation obj)
 
 testExplicit2 :: Assertion
@@ -628,7 +629,7 @@
 
 testCompound0 :: Assertion
 testCompound0 = do
-    let bs = fromJust $ unhexlify "0100"
+    let bs = unhexlify "0100"
         act = parseNonSpare (schema @(RecordOf Cat_000_1_0 ~> "091") Proxy)
         result = parse @StrictParsing act bs
     assertEqual "result" True (isLeft result)
@@ -636,9 +637,9 @@
 testCompoundFspecError :: Assertion
 testCompoundFspecError = do
     let -- error: fspec bit is set between 'I1' and 'I2'
-        bs1 = fromJust $ unhexlify "c01122"
+        bs1 = unhexlify "c01122"
         -- error: fspec bit is set between 'I1' and 'I2'
-        bs2 = fromJust $ unhexlify "a21122"
+        bs2 = unhexlify "a21122"
         act = parseNonSpare (schema @(RecordOf Cat_000_1_0 ~> "092") Proxy)
         result1 = parse @StrictParsing act bs1
         result2 = parse @StrictParsing act bs2
@@ -728,7 +729,7 @@
 
 testRecordEmpty :: Assertion
 testRecordEmpty = do
-    let bs = fromJust $ unhexlify "0101010100"
+    let bs = unhexlify "0101010100"
         env = Env parsingStore bs
         actStrict  = parseRecord @StrictParsing (schema @(RecordOf Cat_000_1_0) Proxy)
         actPartial = parseRecord @PartialParsing (schema @(RecordOf Cat_000_1_0) Proxy)
@@ -808,7 +809,7 @@
                *: nil )
            *: nil )
         bs = "410104030602AA02550112340A03040B03040C01FF"
-        bs' = fromJust $ unhexlify bs
+        bs' = unhexlify bs
     assertUnparse bs withRfs
 
     let _i000 = fromJust $ getItem @"000" withRfs
@@ -832,7 +833,7 @@
     let check r expected = do
             assertUnparse expected r
             let act = parseRecord (schema @(RecordOf Cat_003_1_0) Proxy)
-                bs = fromJust $ unhexlify expected
+                bs = unhexlify expected
                 result = parse @StrictParsing act bs
             readback <- either (assertFailure . show) pure result
             assertEqual "readback" (toBits bs) (unparse readback)
@@ -931,13 +932,13 @@
            *: nil )
         datagram :: SBuilder = unparse db0 <> unparse db1
     assertEqual "unparse"
-        (fromJust $ unhexlify "000009800001800002010009800001800002")
+        (unhexlify "000009800001800002010009800001800002")
         (toByteString datagram)
 
 testParse1 :: Assertion
 testParse1 = forM_ samples $ \sample -> do
     let act = parseRecord (schema @(RecordOf Cat_000_1_0) Proxy)
-        bs = fromJust $ unhexlify sample
+        bs = unhexlify sample
         env = Env @StrictParsing parsingStore bs
         result = runParsing act env 0
     (r, o) <- either (assertFailure . show) pure result
diff --git a/test/TestBits.hs b/test/TestBits.hs
--- a/test/TestBits.hs
+++ b/test/TestBits.hs
@@ -1,14 +1,17 @@
-{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE LambdaCase        #-}
+{-# LANGUAGE OverloadedStrings #-}
 
 module TestBits (tests) where
 
 import qualified Data.ByteString       as BS
+import qualified Data.Text             as T
 
 import           Test.Tasty
 import           Test.Tasty.HUnit
 import           Test.Tasty.QuickCheck as QC
 
 import           Asterix.BitString
+import           Common
 
 tests :: TestTree
 tests = testGroup "Bits"
@@ -69,7 +72,7 @@
 testBsToBools :: TestTree
 testBsToBools = testGroup "BsToBools" (fmap check samples)
   where
-    check (x, y) = testCase (hexlify $ BS.pack x) $
+    check (x, y) = testCase (T.unpack . hexlify $ BS.pack x) $
         bitsToBools (byteStringToBits $ BS.pack x) @?= y
     samples =
         [ ([], [])
diff --git a/test/TestCoding.hs b/test/TestCoding.hs
--- a/test/TestCoding.hs
+++ b/test/TestCoding.hs
@@ -1,4 +1,5 @@
-{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DataKinds         #-}
+{-# LANGUAGE OverloadedStrings #-}
 
 -- | Unsorted Coding tests
 
diff --git a/test/TestRawDatablock.hs b/test/TestRawDatablock.hs
--- a/test/TestRawDatablock.hs
+++ b/test/TestRawDatablock.hs
@@ -1,10 +1,12 @@
+{-# LANGUAGE OverloadedStrings #-}
+
 module TestRawDatablock (tests) where
 
 import           Data.ByteString         (ByteString)
 import qualified Data.ByteString         as BS
 import           Data.ByteString.Builder as BSB
 import           Data.Either
-import           Data.Maybe
+import           Data.Text               (Text)
 import           Data.Word
 import           Test.Tasty
 import           Test.Tasty.HUnit
@@ -12,6 +14,7 @@
 
 import           Asterix.Base
 import           Asterix.BitString
+import           Common
 
 allowCategory :: Word8 -> RawDatablock -> Bool
 allowCategory n db = rawDatablockCategory db == n
@@ -27,18 +30,18 @@
     Right lst -> mconcat (unparseRawDatablock <$> reverse lst)
 
 -- e.g.: received from the network
-samples :: [String]
+samples :: [Text]
 samples =
     [ "01000401" -- cat1
     , "01000401" -- cat1
     , "02000402" -- cat2
     ]
 
-allZeros :: String
+allZeros :: Text
 allZeros = "00000000000000000000"
 
 datagramIn :: ByteString
-datagramIn = fromJust $ unhexlify $ mconcat samples
+datagramIn = unhexlify $ mconcat samples
 
 tests :: TestTree
 tests = testGroup "RawDatablock"
@@ -49,10 +52,10 @@
     , testCase "filter 1" $ checkFilter 1 cat1
     , testCase "filter 2" $ checkFilter 2 cat2
     , testCase "reverse" $ assertEqual "sample"
-        (fromJust $ unhexlify $ mconcat $ reverse samples)
+        (unhexlify $ mconcat $ reverse samples)
         (builderToByteStringSlow $ reverseDatablocks datagramIn)
     , testCase "all zeros" $ assertEqual "sample"
-        True (isLeft $ parseRawDatablocks $ fromJust $ unhexlify allZeros)
+        True (isLeft $ parseRawDatablocks $ unhexlify allZeros)
     , testProperty "random input" $ withMaxSuccess 10_000 $ \(lst :: [Word8]) ->
         let bs = BS.pack lst
             result = parseRawDatablocks bs
