diff --git a/kwant/solvers/sparse.py b/kwant/solvers/sparse.py
index 5d3d4737ac1f2b5d839ea16cd8135f1dfd09bfd9..fafb55b40f57c1995cec253065455f613a4b123b 100644
--- a/kwant/solvers/sparse.py
+++ b/kwant/solvers/sparse.py
@@ -15,11 +15,8 @@ from kwant import physics, system
 # reached all of our users.
 def del_for_umfpackcontext(self):
     self.free()
-try:
-    if not hasattr(spl.dsolve.umfpack.UmfpackContext, '__del__'):
-        spl.dsolve.umfpack.UmfpackContext.__del__ = del_for_umfpackcontext
-except:
-    pass
+if not hasattr(umfpack.UmfpackContext, '__del__'):
+    umfpack.UmfpackContext.__del__ = del_for_umfpackcontext
 del del_for_umfpackcontext
 
 def factorized(A, piv_tol=1.0, sym_piv_tol=1.0):
diff --git a/kwant/solvers/tests/test_sparse.py b/kwant/solvers/tests/test_sparse.py
index 06ef4d3f7f6673e7ac757e4f3a7c6bcf81c5e0d3..7e1aebe0b2de8f1f5923b3155f11490c4f1a2dc5 100644
--- a/kwant/solvers/tests/test_sparse.py
+++ b/kwant/solvers/tests/test_sparse.py
@@ -280,4 +280,7 @@ def test_very_singular_leads():
     sys.attach_lead(right_lead)
     fsys = sys.finalized()
     result = solve(fsys)
-    assert result[1] == [0, 2]
\ No newline at end of file
+    assert result[1] == [0, 2]
+
+def test_umfpack_del():
+    assert hasattr(kwant.solvers.sparse.umfpack.UmfpackContext, '__del__')