Fix typeof compare to undefined tests

When comparing typeof results the thing it is compared to should also be a string. Comparing typeof to undefined rather than "undefined" is improper