diff --git a/Text/Hastache/Context.hs b/Text/Hastache/Context.hs
--- a/Text/Hastache/Context.hs
+++ b/Text/Hastache/Context.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE CPP #-}
 -- Module:      Text.Hastache.Context
 -- Copyright:   Sergey S Lymar (c) 2011-2013 
 -- License:     BSD3
@@ -170,7 +171,12 @@
 @
 
 -}
+                    
+#if MIN_VERSION_base(4,7,0)                    
+mkGenericContext :: (Monad m, Data a, Typeable m) => a -> MuContext m
+#else                    
 mkGenericContext :: (Monad m, Data a, Typeable1 m) => a -> MuContext m
+#endif                    
 mkGenericContext val = toGenTemp val ~> convertGenTempToContext
     
 data TD m = 
@@ -180,12 +186,20 @@
     | TUnknown
     deriving (Show)
 
+#if MIN_VERSION_base(4,7,0)                                 
+toGenTemp :: (Data a, Monad m, Typeable m) => a -> TD m
+#else
 toGenTemp :: (Data a, Monad m, Typeable1 m) => a -> TD m
+#endif             
 toGenTemp a = zip fields (gmapQ procField a) ~> TObj
     where
     fields = toConstr a ~> constrFields
 
+#if MIN_VERSION_base(4,7,0) 
+procField :: (Data a, Monad m, Typeable m) => a -> TD m
+#else
 procField :: (Data a, Monad m, Typeable1 m) => a -> TD m
+#endif
 procField = 
     obj
     `ext1Q` list
diff --git a/hastache.cabal b/hastache.cabal
--- a/hastache.cabal
+++ b/hastache.cabal
@@ -1,5 +1,5 @@
 name:            hastache
-version:         0.5.0
+version:         0.5.1
 license:         BSD3
 license-file:    LICENSE
 category:        Text
@@ -7,9 +7,6 @@
 author:          Sergey S Lymar <sergey.lymar@gmail.com>
 maintainer:      Sergey S Lymar <sergey.lymar@gmail.com>
 stability:       experimental
-tested-with:     
-                 GHC == 7.0.2,
-                 GHC == 7.0.3
 synopsis:        Haskell implementation of Mustache templates
 cabal-version:   >= 1.8
 homepage:        http://github.com/lymar/hastache
@@ -19,7 +16,7 @@
     Haskell implementation of Mustache templates (<http://mustache.github.com/>).
     .
     See homepage for examples of usage: <http://github.com/lymar/hastache>
-    
+
 extra-source-files:
     tests/partFile
     tests/RunTest.sh
@@ -57,6 +54,7 @@
   build-depends:
     hastache
    ,base == 4.*
+   ,directory
    ,mtl
    ,HUnit
    ,text
diff --git a/tests/test.hs b/tests/test.hs
--- a/tests/test.hs
+++ b/tests/test.hs
@@ -7,6 +7,8 @@
 import Data.Char
 import Data.Data
 import Data.Generics
+import System.Directory
+import System.Exit
 import Test.HUnit
 import Text.Hastache
 import Text.Hastache.Context
@@ -56,7 +58,7 @@
     context "Text" = MuVariable (T.pack "hello - привет")
     context "String" = MuVariable "hello - привет"
     context "HtmlString" = MuVariable "<p>text (\\)</p>"
-    
+
     testRes  = "\
         \   Char:               [ Й ]            \n\
         \   Double:             [ 123.45 ]          \n\
@@ -108,7 +110,7 @@
     context "nonEmptyString" = MuVariable "some"
     context "nonEmptyInt" = MuVariable (1 :: Int)
     context "nonEmptyDouble" = MuVariable (1 :: Double)
-    
+
     testRes = "\
         \no context : Should render\n\
         \text 1\n\
@@ -174,7 +176,7 @@
     context "bool_true" = MuBool True
     context "bool_false" = MuBool False
     context "someval" = MuVariable "val"
-    
+
     testRes = "\
         \text 1\n\
         \   true: val \n\
@@ -194,7 +196,7 @@
         \text 2\n\
         \"
     context "function" = MuLambda BS.reverse
-    
+
     testRes = "\
         \text 1\n\
         \olleH\n\
@@ -254,7 +256,7 @@
         \text 2\n\
         \"
     context "someVar" = MuVariable "some value"
-    
+
     testRes = "\
         \text 1\n\
         \some value\n\
@@ -275,7 +277,7 @@
         \text 2\n\
         \"
     context "name" = MuVariable "Neo"
-    
+
     testRes = "\
         \text 1\n\
         \Hi, Neo!\n\
@@ -287,7 +289,7 @@
     intDataField2   :: Int
     }
     deriving (Data, Typeable)
-    
+
 data SomeData = SomeData {
     someDataField1      :: String,
     someDataInternal    :: InternalData,
@@ -302,7 +304,7 @@
 
 -- Make hastache context from Data.Data deriving type
 genericContextTest = do
-    res <- hastacheStr defaultConfig (encodeStr template) 
+    res <- hastacheStr defaultConfig (encodeStr template)
         (mkGenericContext context)
     assertEqualStr resCorrectness (decodeStrLBS res) testRes
     where
@@ -330,7 +332,7 @@
         \"
     context = SomeData {
         someDataField1 = "aaa",
-        someDataInternal = InternalData { 
+        someDataInternal = InternalData {
             intDataField1 = "zzz", intDataField2 = 100 },
         someDataList = [1,2,3],
         someDataObjList = [InternalData "a" 1, InternalData "b" 2,
@@ -340,7 +342,7 @@
         someMuLambdaMBS = return . BS.reverse,
         someMuLambdaMS = return . map toUpper
         }
-    
+
     testRes = "\
         \text 1\n\
         \aaa zzz \n\
@@ -451,14 +453,14 @@
         \"
 
 -- Accessing array item by index (generic version)
-data ArrayItemTest_Item = ArrayItemTest_Item { 
-    name :: String 
-    } deriving (Data, Typeable)    
+data ArrayItemTest_Item = ArrayItemTest_Item {
+    name :: String
+    } deriving (Data, Typeable)
 
-data ArrayItemTest_Container = ArrayItemTest_Container { 
+data ArrayItemTest_Container = ArrayItemTest_Container {
     items       :: [ArrayItemTest_Item],
     itemsStr    :: [String]
-    } deriving (Data, Typeable)    
+    } deriving (Data, Typeable)
 
 arrayItemsTestGeneric = do
     res <- hastacheStr defaultConfig (encodeStr template) context
@@ -491,19 +493,22 @@
     , TestLabel "Partials test" (TestCase partialsTest)
     , TestLabel "Generic context test" (TestCase genericContextTest)
     , TestLabel "Nested context test" (TestCase nestedContextTest)
-    , TestLabel "Nested generic context test" 
+    , TestLabel "Nested generic context test"
                                         (TestCase nestedGenericContextTest)
     , TestLabel "Accessing array item by index" (TestCase arrayItemsTest)
-    , TestLabel "Accessing array item by index (generic version)" 
+    , TestLabel "Accessing array item by index (generic version)"
         (TestCase arrayItemsTestGeneric)
     ]
 
 main = do
-    runTestTT tests
+    setCurrentDirectory "./tests/"
+    trs <- runTestTT tests
+    if (errors trs /= 0) || (failures trs /= 0)
+        then exitFailure
+        else exitSuccess
 
 assertEqualStr preface actual expected =
     unless (actual == expected) (assertFailure msg)
-    where 
+    where
     msg = (if null preface then "" else preface ++ "\n") ++
         "expected: \n" ++ expected ++ "\nbut got: \n" ++ actual
-
