Added tests and deleted unnecessary code