Dereference patch

Fix + unit test for issue 249