add logging and refactor tests cases