use reflect module in type tests, updated version that supports metatables