diff --git a/unittest/python/test_return_by_ref.py b/unittest/python/test_return_by_ref.py
index 969f84672335af20ec65b1d91cb64e26c17f1830..59f6d130a9925bc772d55cd70cc5b9eed1e05e38 100644
--- a/unittest/python/test_return_by_ref.py
+++ b/unittest/python/test_return_by_ref.py
@@ -1,7 +1,8 @@
+import return_by_ref
 from return_by_ref import Matrix, RowMatrix, Vector
 import numpy as np
 
-def test(mat):
+def test_shared(mat):
 
   m_ref = mat.ref()
   m_ref.fill(0)
@@ -22,6 +23,27 @@ def test(mat):
   except:
     assert True
 
+def test_not_shared(mat):
+
+  m_ref = mat.ref()
+  m_ref.fill(100.)
+  m_copy = mat.copy()
+  assert not np.array_equal(m_ref,m_copy)
+
+  m_const_ref = mat.const_ref()
+  assert np.array_equal(m_const_ref,m_copy)
+  assert not np.array_equal(m_const_ref,m_ref)
+
+  m_ref.fill(10.)
+  assert not np.array_equal(m_ref,m_copy)
+  assert not np.array_equal(m_const_ref,m_ref)
+
+  try:
+    m_const_ref.fill(2)
+    assert True
+  except:
+    assert False
+
 rows = 10
 cols = 30
 
@@ -29,6 +51,13 @@ mat = Matrix(rows,cols)
 row_mat = RowMatrix(rows,cols)
 vec = Vector(rows,1)
 
-test(mat)
-test(row_mat)
-test(vec)
+test_shared(mat)
+test_shared(row_mat)
+test_shared(vec)
+
+return_by_ref.sharedMemory(False)
+test_not_shared(mat)
+test_not_shared(row_mat)
+test_not_shared(vec)
+
+