added type-checking functions and tests