Add information type (Warning, Error, ...) to diagnostic message
minor code refactoring and better diagnostic message
add more unit tests