Fixed memory corruption.

    - this commit makes yang parser stable
    - fixed memory corruption bug from previous commit - caused
      by me not understanding realloc properly
    - fixed several more memory corruption occurrences
    - streamlined some functions
    - new test on reading whole modules from files