Fix set reference to none

Delete all connections to reference node if there is any.
Fix delete node

Add test for delete. Disconnect refobj before deletion.