add and fix unit tests