diff --git a/.travis.yml b/.travis.yml
index a362ea6bb6d3c01e582d86e317f8a2301b1d8670..5b73a24953a913f0195c2c1ffd9582d64b7d62d6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -23,7 +23,7 @@ install:
   - pip install drmaa 
   - sudo adduser --quiet --disabled-password --gecos TEST u1  ## Create user for run-as-user test.  
 #  - sudo apt-get install condor
-script: . local_env.sh; pyflakes lwr test && flake8 lwr test && nosetests
+script: . local_env.sh; pyflakes lwr test && flake8 --max-complexity 10 lwr test && nosetests
 after_success:
   - coveralls
 
diff --git a/lwr/framework.py b/lwr/framework.py
index 593bde45bf4e4ff830fcacc61d572afb6330986d..16bd79690899ab96a7e564aef3f99ef84305b434 100644
--- a/lwr/framework.py
+++ b/lwr/framework.py
@@ -94,38 +94,56 @@ class Controller(object):
             if func_arg not in args and func_arg in arg_values:
                 args[func_arg] = arg_values[func_arg]
 
+    def __handle_access(self, req, environ, start_response):
+        access_response = None
+        if hasattr(self, '_check_access'):
+            access_response = self._check_access(req, environ, start_response)
+        return access_response
+
+    def __build_args(self, func, args, req, environ):
+        args = build_func_args(func, args, req.GET, self._app_args(args, req))
+        func_args = inspect.getargspec(func).args
+
+        for func_arg in func_args:
+            if func_arg == "ip":
+                args["ip"] = self.__get_client_address(environ)
+
+        if 'body' in func_args:
+            args['body'] = req.body_file
+
+        return args
+
+    def __execute_request(self, func, args, req, environ):
+        args = self.__build_args(func, args, req, environ)
+        try:
+            result = func(**args)
+        except exc.HTTPException as e:
+            result = e
+        return result
+
+    def __build_response(self, result):
+        if self.response_type == 'file':
+            resp = Response()
+            path = result
+            if exists(path):
+                resp.app_iter = FileIterator(path)
+            else:
+                raise exc.HTTPNotFound("No file found with path %s." % path)
+        else:
+            resp = Response(body=self.body(result))
+        return resp
+
     def __call__(self, func):
         def controller_replacement(environ, start_response, **args):
             req = Request(environ)
 
-            if hasattr(self, '_check_access'):
-                access_response = self._check_access(req, environ, start_response)
-                if access_response:
-                    return access_response
-
-            args = build_func_args(func, args, req.GET, self._app_args(args, req))
-            func_args = inspect.getargspec(func).args
-
-            for func_arg in func_args:
-                if func_arg == "ip":
-                    args["ip"] = self.__get_client_address(environ)
-
-            if 'body' in func_args:
-                args['body'] = req.body_file
-
-            try:
-                result = func(**args)
-            except exc.HTTPException as e:
-                result = e
-            if self.response_type == 'file':
-                resp = Response()
-                path = result
-                if exists(path):
-                    resp.app_iter = FileIterator(path)
-                else:
-                    raise exc.HTTPNotFound("No file found with path %s." % path)
-            else:
-                resp = Response(body=self.body(result))
+            access_response = self.__handle_access(req, environ, start_response)
+            if access_response:
+                return access_response
+
+            result = self.__execute_request(func, args, req, environ)
+            resp = self.__build_response(result)
+
             return resp(environ, start_response)
         controller_replacement.func = func
         controller_replacement.response_type = self.response_type
diff --git a/lwr/lwr_client/client.py b/lwr/lwr_client/client.py
index 9153d306f14cd42e4207af7ee286f52a1e660ed3..9172e1371219c14e8588f695a0d33ee981ce58fc 100644
--- a/lwr/lwr_client/client.py
+++ b/lwr/lwr_client/client.py
@@ -132,21 +132,21 @@ class Client(object):
         """
         name = os.path.basename(path)
         output_type = self._get_output_type(name)
+
+        if output_type == "none":
+            # Just make sure the file was created.
+            if not os.path.exists(path):
+                raise OutputNotFoundException(path)
+            return
+
         if output_type == "direct":
             output_path = path
         elif output_type == "task":
             output_path = os.path.join(working_directory, name)
-        elif output_type == "none":
-            if action == "transfer":
-                raise OutputNotFoundException(path)
         else:
             raise Exception("Unknown output_type returned from LWR server %s" % output_type)
         if action == 'transfer':
             self.__raw_download_output(name, self.job_id, output_type, output_path)
-        elif output_type == 'none':
-            # Just make sure the file was created.
-            if not os.path.exists(path):
-                raise OutputNotFoundException(path)
         elif action == 'copy':
             lwr_path = self._output_path(name, self.job_id, output_type)['path']
             self._copy(lwr_path, output_path)
diff --git a/lwr/managers/util/kill.py b/lwr/managers/util/kill.py
index 94448f7524c21071004334c4a85dfa67b35d1757..6d092044c3eb94e598361a0138af0e974958c0b3 100644
--- a/lwr/managers/util/kill.py
+++ b/lwr/managers/util/kill.py
@@ -31,27 +31,35 @@ def _psutil_kill_pid(pid):
 
 
 def _stock_kill_pid(pid):
-    def __check_pid():
+    is_windows = system() == 'Windows'
+
+    if is_windows:
+        __kill_windows(pid)
+    else:
+        __kill_posix(pid)
+
+
+def __kill_windows(pid):
+    try:
+        Popen("taskkill /F /T /PID %i" % pid, shell=True)
+    except Exception:
+        pass
+
+
+def __kill_posix(pid):
+    def __check_pid(pid):
         try:
             os.kill(pid, 0)
             return True
         except OSError:
             return False
 
-    is_windows = system() == 'Windows'
-
-    if is_windows:
-        try:
-            Popen("taskkill /F /T /PID %i" % pid, shell=True)
-        except Exception:
-            pass
-    else:
-        if __check_pid():
-            for sig in [15, 9]:
-                try:
-                    os.killpg(pid, sig)
-                except OSError:
-                    return
-                sleep(1)
-                if not __check_pid():
-                    return
+    if __check_pid():
+        for sig in [15, 9]:
+            try:
+                os.killpg(pid, sig)
+            except OSError:
+                return
+            sleep(1)
+            if not __check_pid():
+                return
diff --git a/test/test_utils.py b/test/test_utils.py
index 7e89f6d991b10c39a06172b7adcbd1d40a5fc5ed..581377135b0ea4acd7e2dda29c871ba051e5e497 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -51,10 +51,17 @@ class TestManager(object):
 
 @contextmanager
 def test_job_directory():
-    temp_directory = mkdtemp()
-    job_directory = JobDirectory(temp_directory, '1')
-    yield job_directory
-    rmtree(temp_directory)
+    with temp_directory() as directory:
+        yield JobDirectory(directory, '1')
+
+
+@contextmanager
+def temp_directory():
+    directory = mkdtemp()
+    try:
+        yield directory
+    finally:
+        rmtree(directory)
 
 
 @contextmanager