adds unit tests and remove unnecessary piece of code