Fix unit tests and apply review comments