Add logging & fix unit tests