Add tests for case insensitive methods. Fix memleaks.