Type test: Add test for Ref of function validation.
Type: Refactor Table.

* On bad type declaration, throw LlamaBadTypeError.
* Split type processing into functions for readability.