Fix to_dict. Add unittest for to_dict of analzer.