[IR] Methods defined in class methods should be added to self

* Fixed the instance method container logic to distinguish between
  instance and class method scope types.

* Fixes issue 1239 without breaking anything else.