Added more tests and implementation