Extract typeOf to it's own file

This one was easy, it already had plenty of tests :)