Added type() function and tests