unit tests and changes according to comments