Type assertion unit tests and fix for destructuring breaking normal function parameters