Improved delete functionality, added more tests