Addressed some review feedback
- Used typeof instead of $.type
- Explicitly handle undefined & null
- Added unit tests for all cases
- Updated functional test to cover undefined & null case
- #327