diff --git a/client/tests/cgroup/cgroup.py b/client/tests/cgroup/cgroup.py
index dc5a1b3..0f56ad5 100755
--- a/client/tests/cgroup/cgroup.py
+++ b/client/tests/cgroup/cgroup.py
@@ -4,6 +4,7 @@ import os, logging
 import time
 from cgroup_common import Cgroup as CG
 from cgroup_common import CgroupModules
+from tempfile import NamedTemporaryFile
 
 class cgroup(test.test):
     """
@@ -13,7 +14,6 @@ class cgroup(test.test):
     _client = ""
     modules = CgroupModules()
 
-
     def run_once(self):
         """
 	    Try to access different resources which are restricted by cgroup.
@@ -80,6 +80,7 @@ class cgroup(test.test):
                 err += "\nCan't remove cgroup directory"
 
             os.system("swapon -a")
+
             if err:
                 if supress:
                     logging.warn("Some parts of cleanup failed%s" % err)
@@ -126,6 +127,8 @@ class cgroup(test.test):
             logging.info("'memsw' not supported")
             os.system("swapoff -a")
             memsw = False
+        outf = NamedTemporaryFile('w+', prefix="cgroup_client-",
+                                       dir="/tmp")
         logging.debug("test_memory: Initializition passed")
 
         ################################################
@@ -133,7 +136,7 @@ class cgroup(test.test):
         # Should pass
         ################################################
         logging.debug("test_memory: Memfill WO cgroup")
-        ps = item.test("memfill %d" % mem)
+        ps = item.test("memfill %d %s" % (mem, outf.name))
         ps.stdin.write('\n')
         i = 0
         while ps.poll() == None:
@@ -144,10 +147,12 @@ class cgroup(test.test):
         if i > 60:
             ps.terminate()
             raise error.TestFail("Memory filling failed (WO cgroup)")
-        out = ps.stdout.readlines()
+        outf.seek(0)
+        outf.flush()
+        out = outf.readlines()
         if (len(out) < 2) or (ps.poll() != 0):
             raise error.TestFail("Process failed (WO cgroup); output:\n%s"
-                          "\nReturn: %d", out, ps.poll())
+                          "\nReturn: %d" % (out, ps.poll()))
         if not out[-1].startswith("PASS"):
             raise error.TestFail("Unsuccessful memory filling "
                           "(WO cgroup)")
@@ -159,7 +164,7 @@ class cgroup(test.test):
         # WO memsw: should fail (SIGKILL)
         ################################################
         logging.debug("test_memory: Memfill mem only limit")
-        ps = item.test("memfill %d" % mem)
+        ps = item.test("memfill %d %s" % (mem, outf.name))
         if item.set_cgroup(ps.pid, pwd):
             raise error.TestFail("Could not set cgroup")
         if item.set_prop("memory.limit_in_bytes", ("%dM" % (mem/2)), pwd):
@@ -167,17 +172,19 @@ class cgroup(test.test):
         ps.stdin.write('\n')
         i = 0
         while ps.poll() == None:
-            if i > 60:
+            if i > 120:
                 break
             i += 1
             time.sleep(1)
-        if i > 60:
+        if i > 120:
             ps.terminate()
             raise error.TestFail("Memory filling failed (mem)")
-        out = ps.stdout.readlines()
-        if (len(out)) < 2 or (ps.poll() != 0):
+        outf.seek(0)
+        outf.flush()
+        out = outf.readlines()
+        if (len(out) < 2):
             raise error.TestFail("Process failed (mem); output:\n%s"
-                          "\nReturn: %d", out, ps.poll())
+                          "\nReturn: %d" % (out, ps.poll()))
         if memsw:
             if not out[-1].startswith("PASS"):
                 logging.error("test_memory: cgroup_client.py returned %d; "
@@ -199,10 +206,11 @@ class cgroup(test.test):
         ################################################
         # Fill the memory with 1/2 memory+swap limit
         # Should fail
+        # (memory.limit_in_bytes have to be set prior to this test)
         ################################################
-        logging.debug("test_memory: Memfill mem + swap limit")
         if memsw:
-            ps = item.test("memfill %d" % mem)
+            logging.debug("test_memory: Memfill mem + swap limit")
+            ps = item.test("memfill %d %s" % (mem, outf.name))
             if item.set_cgroup(ps.pid, pwd):
                 raise error.TestFail("Could not set cgroup (memsw)")
             if item.set_prop("memory.memsw.limit_in_bytes", "%dM"%(mem/2), pwd):
@@ -210,17 +218,19 @@ class cgroup(test.test):
             ps.stdin.write('\n')
             i = 0
             while ps.poll() == None:
-                if i > 60:
+                if i > 120:
                     break
                 i += 1
                 time.sleep(1)
-            if i > 60:
+            if i > 120:
                 ps.terminate()
                 raise error.TestFail("Memory filling failed (mem)")
-            out = ps.stdout.readlines()
-            if (len(out) < 2) or (ps.poll() != 0):
+            outf.seek(0)
+            outf.flush()
+            out = outf.readlines()
+            if (len(out) < 2):
                 raise error.TestFail("Process failed (memsw); output:\n%s"
-                              "\nReturn: %d", out, ps.poll())
+                              "\nReturn: %d" % (out, ps.poll()))
             if out[-1].startswith("PASS"):
                 raise error.TestFail("Unexpected memory filling (memsw)",
                               mem)
diff --git a/client/tests/cgroup/cgroup_client.py b/client/tests/cgroup/cgroup_client.py
index 03553c4..ab7311a 100755
--- a/client/tests/cgroup/cgroup_client.py
+++ b/client/tests/cgroup/cgroup_client.py
@@ -7,8 +7,9 @@ Interactive python script for testing cgroups
 @author: Lukas Doktor <ldoktor@redhat.com>
 """
 import array, sys, time, math, os
+from tempfile import mktemp
 
-def test_smoke():
+def test_smoke(args):
     """
     SIGSTOP the process and after SIGCONT exits.
     """
@@ -18,12 +19,20 @@ def test_smoke():
     print "PASS: smoke"
 
 
-def test_memfill(size=1024):
+def test_memfill(args):
     """
     SIGSTOP and after SIGCONT fills the memory up to size size.
     """
+    size = 1024
+    f = sys.stdout
+    if args:
+        size = int(args[0])
+        if len(args) > 1:
+            f = open(args[1], 'w', 0)
     print "TEST: memfill (%dM)" % size
-    print "TEST: wait for input"
+    print "Redirecting to: %s" % f.name
+    f.write("TEST: memfill (%dM)\n" % size)
+    f.write("TEST: wait for input\n")
     raw_input()
     mem = array.array('B')
     buf = ""
@@ -31,14 +40,16 @@ def test_memfill(size=1024):
         buf += '\x00'
     for i in range(size):
         mem.fromstring(buf)
-        #for j in range(1024*1024):
-        #    mem.append(0)
-        print "TEST: %dM" % i
-        sys.stdout.flush()
-    print "PASS: memfill (%dM)" % size
+        f.write("TEST: %dM\n" % i)
+        try:
+            f.flush()
+            os.fsync(f)
+        except:
+            pass
+    f.write("PASS: memfill (%dM)\n" % size)
 
 
-def test_cpu():
+def test_cpu(args):
     """
     Stress the CPU
     """
@@ -50,6 +61,16 @@ def test_cpu():
             math.factorial(i)
 
 
+def test_devices(args):
+    if args:
+        if args[0] == "write":
+            test_devices_write()
+        else:
+            test_devices_read()
+    else:
+        test_devices_read()
+
+
 def test_devices_read():
     """
     Inf read from /dev/zero
@@ -90,27 +111,19 @@ def main():
     Main (infinite) loop.
     """
     if len(sys.argv) < 2:
-        print "FAIL: Incorrect usage"
+        print "FAIL: Incorrect usage (%s)" % sys.argv
         return -1
+    args = sys.argv[2:]
     if sys.argv[1] == "smoke":
-        test_smoke()
+        test_smoke(args)
     elif sys.argv[1] == "memfill":
-        if len(sys.argv) > 2:
-            test_memfill(int(sys.argv[2]))
-        else:
-            test_memfill()
+        test_memfill(args)
     elif sys.argv[1] == "cpu":
-        test_cpu()
+        test_cpu(args)
     elif sys.argv[1] == "devices":
-        if len(sys.argv) > 2:
-            if (sys.argv[2] == "write"):
-                test_devices_write()
-            else:
-                test_devices_read()
-        else:
-            test_devices_read()
+        test_devices(args)
     else:
-        print "FAIL: No test specified"
+        print "FAIL: No test specified (%s)" % sys.argv
 
 if __name__ == "__main__":
     main()
