diff --git a/lib/spack/spack/test/__init__.py b/lib/spack/spack/test/__init__.py
index cd842561e6c1f957c32f3a245366f9220dd26698..175a49428c4b223f99814b541e71965bd7585dae 100644
--- a/lib/spack/spack/test/__init__.py
+++ b/lib/spack/spack/test/__init__.py
@@ -67,7 +67,8 @@
               'namespace_trie',
               'yaml',
               'sbang',
-              'environment']
+              'environment',
+              'cmd.uninstall']
 
 
 def list_tests():
diff --git a/lib/spack/spack/test/cmd/__init__.py b/lib/spack/spack/test/cmd/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/lib/spack/spack/test/cmd/uninstall.py b/lib/spack/spack/test/cmd/uninstall.py
new file mode 100644
index 0000000000000000000000000000000000000000..06a24e2958bf7abbb0926c396013f1afbfba1f81
--- /dev/null
+++ b/lib/spack/spack/test/cmd/uninstall.py
@@ -0,0 +1,37 @@
+import spack.test.mock_database
+
+from spack.cmd.uninstall import uninstall
+
+
+class MockArgs(object):
+    def __init__(self, packages, all=False, force=False, recursive=False):
+        self.packages = packages
+        self.all = all
+        self.force = force
+        self.recursive = recursive
+        self.yes_to_all = True
+
+
+class TestUninstall(spack.test.mock_database.MockDatabase):
+    def test_uninstall(self):
+        parser = None
+        # Multiple matches
+        args = MockArgs(['mpileaks'])
+        self.assertRaises(SystemExit, uninstall, parser, args)
+        # Installed dependents
+        args = MockArgs(['libelf'])
+        self.assertRaises(SystemExit, uninstall, parser, args)
+        # Recursive uninstall
+        args = MockArgs(['callpath'], all=True, recursive=True)
+        uninstall(parser, args)
+
+        all_specs = spack.install_layout.all_specs()
+        self.assertEqual(len(all_specs), 7)
+        # query specs with multiple configurations
+        mpileaks_specs = [s for s in all_specs if s.satisfies('mpileaks')]
+        callpath_specs = [s for s in all_specs if s.satisfies('callpath')]
+        mpi_specs = [s for s in all_specs if s.satisfies('mpi')]
+
+        self.assertEqual(len(mpileaks_specs), 0)
+        self.assertEqual(len(callpath_specs), 0)
+        self.assertEqual(len(mpi_specs),      3)
diff --git a/lib/spack/spack/test/database.py b/lib/spack/spack/test/database.py
index ce6e8a0552ba82f3f4182874f8b3a86ae7f5f9e0..465263d057465d57667c11f4cfd425ef0a1157c1 100644
--- a/lib/spack/spack/test/database.py
+++ b/lib/spack/spack/test/database.py
@@ -28,16 +28,12 @@
 """
 import os.path
 import multiprocessing
-import shutil
-import tempfile
 
 import spack
 from llnl.util.filesystem import join_path
 from llnl.util.lock import *
 from llnl.util.tty.colify import colify
-from spack.database import Database
-from spack.directory_layout import YamlDirectoryLayout
-from spack.test.mock_packages_test import *
+from spack.test.mock_database import MockDatabase
 
 
 def _print_ref_counts():
@@ -75,80 +71,7 @@ def add_rec(spec):
     colify(recs, cols=3)
 
 
-class DatabaseTest(MockPackagesTest):
-
-    def _mock_install(self, spec):
-        s = Spec(spec)
-        s.concretize()
-        pkg = spack.repo.get(s)
-        pkg.do_install(fake=True)
-
-
-    def _mock_remove(self, spec):
-        specs = spack.installed_db.query(spec)
-        assert(len(specs) == 1)
-        spec = specs[0]
-        spec.package.do_uninstall(spec)
-
-
-    def setUp(self):
-        super(DatabaseTest, self).setUp()
-        #
-        # TODO: make the mockup below easier.
-        #
-
-        # Make a fake install directory
-        self.install_path = tempfile.mkdtemp()
-        self.spack_install_path = spack.install_path
-        spack.install_path = self.install_path
-
-        self.install_layout = YamlDirectoryLayout(self.install_path)
-        self.spack_install_layout = spack.install_layout
-        spack.install_layout = self.install_layout
-
-        # Make fake database and fake install directory.
-        self.installed_db = Database(self.install_path)
-        self.spack_installed_db = spack.installed_db
-        spack.installed_db = self.installed_db
-
-        # make a mock database with some packages installed note that
-        # the ref count for dyninst here will be 3, as it's recycled
-        # across each install.
-        #
-        # Here is what the mock DB looks like:
-        #
-        # o  mpileaks     o  mpileaks'    o  mpileaks''
-        # |\              |\              |\
-        # | o  callpath   | o  callpath'  | o  callpath''
-        # |/|             |/|             |/|
-        # o |  mpich      o |  mpich2     o |  zmpi
-        #   |               |             o |  fake
-        #   |               |               |
-        #   |               |______________/
-        #   | .____________/
-        #   |/
-        #   o  dyninst
-        #   |\
-        #   | o  libdwarf
-        #   |/
-        #   o  libelf
-        #
-
-        # Transaction used to avoid repeated writes.
-        with spack.installed_db.write_transaction():
-            self._mock_install('mpileaks ^mpich')
-            self._mock_install('mpileaks ^mpich2')
-            self._mock_install('mpileaks ^zmpi')
-
-
-    def tearDown(self):
-        super(DatabaseTest, self).tearDown()
-        shutil.rmtree(self.install_path)
-        spack.install_path = self.spack_install_path
-        spack.install_layout = self.spack_install_layout
-        spack.installed_db = self.spack_installed_db
-
-
+class DatabaseTest(MockDatabase):
     def test_005_db_exists(self):
         """Make sure db cache file exists after creating."""
         index_file = join_path(self.install_path, '.spack-db', 'index.yaml')
@@ -157,7 +80,6 @@ def test_005_db_exists(self):
         self.assertTrue(os.path.exists(index_file))
         self.assertTrue(os.path.exists(lock_file))
 
-
     def test_010_all_install_sanity(self):
         """Ensure that the install layout reflects what we think it does."""
         all_specs = spack.install_layout.all_specs()
diff --git a/lib/spack/spack/test/mock_database.py b/lib/spack/spack/test/mock_database.py
new file mode 100644
index 0000000000000000000000000000000000000000..6fd05439bff2ec8d2e8f06dd2d284c2a57f14b3b
--- /dev/null
+++ b/lib/spack/spack/test/mock_database.py
@@ -0,0 +1,78 @@
+import shutil
+import tempfile
+
+import spack
+from spack.spec import Spec
+from spack.database import Database
+from spack.directory_layout import YamlDirectoryLayout
+from spack.test.mock_packages_test import MockPackagesTest
+
+
+class MockDatabase(MockPackagesTest):
+    def _mock_install(self, spec):
+        s = Spec(spec)
+        s.concretize()
+        pkg = spack.repo.get(s)
+        pkg.do_install(fake=True)
+
+    def _mock_remove(self, spec):
+        specs = spack.installed_db.query(spec)
+        assert(len(specs) == 1)
+        spec = specs[0]
+        spec.package.do_uninstall(spec)
+
+    def setUp(self):
+        super(MockDatabase, self).setUp()
+        #
+        # TODO: make the mockup below easier.
+        #
+
+        # Make a fake install directory
+        self.install_path = tempfile.mkdtemp()
+        self.spack_install_path = spack.install_path
+        spack.install_path = self.install_path
+
+        self.install_layout = YamlDirectoryLayout(self.install_path)
+        self.spack_install_layout = spack.install_layout
+        spack.install_layout = self.install_layout
+
+        # Make fake database and fake install directory.
+        self.installed_db = Database(self.install_path)
+        self.spack_installed_db = spack.installed_db
+        spack.installed_db = self.installed_db
+
+        # make a mock database with some packages installed note that
+        # the ref count for dyninst here will be 3, as it's recycled
+        # across each install.
+        #
+        # Here is what the mock DB looks like:
+        #
+        # o  mpileaks     o  mpileaks'    o  mpileaks''
+        # |\              |\              |\
+        # | o  callpath   | o  callpath'  | o  callpath''
+        # |/|             |/|             |/|
+        # o |  mpich      o |  mpich2     o |  zmpi
+        #   |               |             o |  fake
+        #   |               |               |
+        #   |               |______________/
+        #   | .____________/
+        #   |/
+        #   o  dyninst
+        #   |\
+        #   | o  libdwarf
+        #   |/
+        #   o  libelf
+        #
+
+        # Transaction used to avoid repeated writes.
+        with spack.installed_db.write_transaction():
+            self._mock_install('mpileaks ^mpich')
+            self._mock_install('mpileaks ^mpich2')
+            self._mock_install('mpileaks ^zmpi')
+
+    def tearDown(self):
+        super(MockDatabase, self).tearDown()
+        shutil.rmtree(self.install_path)
+        spack.install_path = self.spack_install_path
+        spack.install_layout = self.spack_install_layout
+        spack.installed_db = self.spack_installed_db