fix and add new unit tests