diff --git a/Setup.lhs b/Setup.lhs
--- a/Setup.lhs
+++ b/Setup.lhs
@@ -6,16 +6,26 @@
 > import Distribution.Simple.Utils ( rawSystemExit )
 > import Distribution.Verbosity ( normal )
 > import System.FilePath ( (</>) )
-
-> main = defaultMainWithHooks hooks
+> import Control.Monad ( forM_, when )
+> import Data.Char ( toLower )
 
-> hooks = simpleUserHooks { instHook = inst
->                         , runTests = test
->                         }
+> main = defaultMainWithHooks $ handleTestExes simpleUserHooks
 
-> inst pkg = instHook simpleUserHooks $ pkg { executables = [] }
+> handleTestExes hooks = hooks { instHook = dropTestExes instHook
+>                              , copyHook = dropTestExes copyHook
+>                              , runTests = runTestExes
+>                              }
+>     where
+>       dropTestExes hook pkg =
+>           let nonTest = filter (not . isTestExe) (executables pkg)
+>           in hook hooks $ pkg { executables = nonTest }
+>
+>       runTestExes args _unknown pkg lbi = do
+>         buildHook hooks pkg lbi hooks defaultBuildFlags
+>         forM_ (executables pkg) $ \exe ->
+>             let testPath = buildDir lbi </> exeName exe </> exeName exe
+>             in when (isTestExe exe) $ rawSystemExit normal testPath args
 
-> test args _unknown pkg lbi = do
->   buildHook hooks pkg lbi hooks defaultBuildFlags
->   let testPath = buildDir lbi </> "test" </> "test"
->   rawSystemExit normal testPath args
+> isTestExe exe =
+>     let fields = customFieldsBI (buildInfo exe)
+>     in ["true"] == [ map toLower val | ("x-test-executable", val) <- fields ]
diff --git a/windowslive.cabal b/windowslive.cabal
--- a/windowslive.cabal
+++ b/windowslive.cabal
@@ -1,6 +1,6 @@
 Name:                windowslive
 Cabal-Version:       >= 1.6
-Version:             0.1.1
+Version:             0.1.1.1
 Synopsis:            Implements Windows Live Web Authentication and
                      Delegated Authentication
 
@@ -40,7 +40,8 @@
 
 -- This executable is not installed by the (custom) Setup program. It is
 -- used by the test hook (cabal test)
-Executable test
+Executable windowslive-library-test
   GHC-Options: -Wall
   Main-is: Test.hs
   HS-Source-Dirs: src, test
+  X-Test-Executable: true
