added tests and improved efficiency for analyzer