put new type under namespace

Not sure what XS has done to the formatting :worried: 
This code isn't quite right.... what if there is no namespace? You probably want to search for the first class instead and insert before that.

Also, please include some tests so I can see what is going on.