Added test code for the remove function and fixed that function