Added tests and deleted unused code