Aded new tests & fixed the code