Fixed algorithm of finding method hierarchies. Added tests