Added unit tests and logging.