diff --git a/slack-api.cabal b/slack-api.cabal
--- a/slack-api.cabal
+++ b/slack-api.cabal
@@ -1,5 +1,5 @@
 Name:                slack-api
-Version:             0.2.1
+Version:             0.3
 Synopsis:            Bindings to the Slack RTM API.
 Description:         This library provides bindings to the <https://api.slack.com/rtm Slack Real Time Messaging API>.
                      Users should find it easy to program their own Slack bots using the functionality found in `Web.Slack`.
@@ -20,7 +20,7 @@
 Stability:           Experimental
 Category:            Web
 Build-type:          Simple
-Cabal-version:       >=1.6
+Cabal-version:       >=1.8
 source-repository head
     type: git
     location: https://github.com/mpickering/slack-api.git
@@ -72,13 +72,21 @@
     lens >= 4.6,
     lens-aeson >= 1.0 ,
     network >= 2.6,
+    network-uri >= 2.6,
     openssl-streams >= 1.2,
     HsOpenSSL >= 0.11 ,
     io-streams >= 1.2,
     mtl >= 2.1,
     aeson >= 0.8 ,
-    time >= 1.4.2,
+    time >= 1.4.2 && < 1.5,
     errors >= 1.4,
     monad-loops >= 0.4,
     transformers >= 0.3
 
+Test-Suite tests
+    Type: exitcode-stdio-1.0
+    Main-Is: tests-main.hs
+    ghc-options:   -threaded
+    HS-Source-Dirs: tests .
+    Build-Depends: slack-api, base
+    Other-Modules: Tests.ConnectionTest
diff --git a/src/Web/Slack.hs b/src/Web/Slack.hs
--- a/src/Web/Slack.hs
+++ b/src/Web/Slack.hs
@@ -19,7 +19,7 @@
 --
 -- > myConfig :: SlackConfig
 -- > myConfig = SlackConfig
--- >         { slackApiToken = "..." -- Specify your API token here
+-- >         { _slackApiToken = "..." -- Specify your API token here
 -- >         }
 -- >
 -- > -- type SlackBot s = Event -> Slack s ()
@@ -51,6 +51,7 @@
 import qualified Data.ByteString.Lazy.Char8 as BC
 import qualified Data.Text                  as T
 import qualified Network.Socket             as S
+import qualified Network.URI                as URI
 import qualified Network.WebSockets         as WS
 import qualified Network.WebSockets.Stream  as WS
 import           Network.Wreq
@@ -85,27 +86,32 @@
   let partialState :: Metainfo -> SlackState s
       partialState metainfo = SlackState metainfo sessionInfo start conf
   putStrLn "rtm.start call successful"
-  let (host, path) = splitAt 19 (drop 6 $ T.unpack url)
-  SSL.withOpenSSL $ do
-    ctx <- SSL.context
-    is  <- S.getAddrInfo Nothing (Just host) (Just $ show port)
-    let a = S.addrAddress $ head is
-        f = S.addrFamily $ head is
-    s <- S.socket f S.Stream S.defaultProtocol
-    S.connect s a
-    ssl <- SSL.connection ctx s
-    SSL.connect ssl
-    (i,o) <- Streams.sslToStreams ssl
-    (stream :: WS.Stream) <- WS.makeStream  (StreamsIO.read i) (\b -> StreamsIO.write (B.toStrict <$> b) o )
-    WS.runClientWithStream stream host path WS.defaultConnectionOptions []
-      (mkBot partialState bot)
+  case parseWebSocketUrl (T.unpack url) of
+    Just (host, path) -> do
+      SSL.withOpenSSL $ do
+        ctx <- SSL.context
+        is  <- S.getAddrInfo Nothing (Just host) (Just $ show port)
+        let a = S.addrAddress $ head is
+            f = S.addrFamily $ head is
+        s <- S.socket f S.Stream S.defaultProtocol
+        S.connect s a
+        ssl <- SSL.connection ctx s
+        SSL.connect ssl
+        (i,o) <- Streams.sslToStreams ssl
+        (stream :: WS.Stream) <- WS.makeStream  (StreamsIO.read i) (\b -> StreamsIO.write (B.toStrict <$> b) o )
+        WS.runClientWithStream stream host path WS.defaultConnectionOptions []
+          (mkBot partialState bot)
+    Nothing -> error $ "Couldn't parse WebSockets URL: " ++ T.unpack url
   where
     port = 443 :: Int
     rtmStartUrl :: String
     rtmStartUrl = "https://slack.com/api/rtm.start?token="
                     ++ (conf ^. slackApiToken)
-
-
+    parseWebSocketUrl :: String -> Maybe (String, String)
+    parseWebSocketUrl url = do
+      uri  <- URI.parseURI url
+      name <- URI.uriRegName <$> URI.uriAuthority uri
+      return (name, URI.uriPath uri)
 
 mkBot :: (Metainfo -> SlackState s) -> SlackBot s -> WS.ClientApp ()
 mkBot partialState bot conn = do
diff --git a/src/Web/Slack/Types/Team.hs b/src/Web/Slack/Types/Team.hs
--- a/src/Web/Slack/Types/Team.hs
+++ b/src/Web/Slack/Types/Team.hs
@@ -27,7 +27,7 @@
                , _teamIcon88      :: URL
                , _teamIcon102     :: URL
                , _teamIcon132     :: URL
-               , _teamIconDefault :: Bool
+               , _teamIconDefault :: Maybe Bool
                } deriving Show
 
 makeLenses ''Team
@@ -49,4 +49,4 @@
                       <*> o .: "image_88"
                       <*> o .: "image_102"
                       <*> o .: "image_132"
-                      <*> o .: "image_default")
+                      <*> o .:? "image_default")
diff --git a/tests/Tests/ConnectionTest.hs b/tests/Tests/ConnectionTest.hs
new file mode 100644
--- /dev/null
+++ b/tests/Tests/ConnectionTest.hs
@@ -0,0 +1,27 @@
+module Tests.ConnectionTest (main) where
+
+import Web.Slack
+import Web.Slack.Message
+import System.Environment (lookupEnv)
+import Data.Maybe (fromMaybe)
+import Control.Applicative
+import System.Exit
+import System.IO.Unsafe
+
+myConfig :: String -> SlackConfig
+myConfig apiToken = SlackConfig
+         { _slackApiToken = apiToken -- Specify your API token here
+         }
+
+connectBot :: SlackBot ()
+connectBot Hello = unsafePerformIO exitSuccess
+connectBot _ = return ()
+
+main :: IO ()
+main = do
+  apiToken <- fromMaybe (unsafePerformIO exitFailure)
+               <$> lookupEnv "SLACK_API_TOKEN"
+  runBot (myConfig apiToken) connectBot ()
+
+
+
diff --git a/tests/tests-main.hs b/tests/tests-main.hs
new file mode 100644
--- /dev/null
+++ b/tests/tests-main.hs
@@ -0,0 +1,5 @@
+module Main where
+
+import qualified Tests.ConnectionTest as C
+
+main = C.main
