[major] Reduce code further, removed pointless function call
[fix] throw error when we receive an invalid type
[test] Added test for thrown error