Solving problem with internal classes

This is my fix, first commit will introduce a test to reproduce the error, the second one will be the fix for it.

Related to #59
Code isn't too obvious indeed. That's why I noticed it. Reading commit till the end I was able to understand what for it was added.