Fixed filetests and new operator when type is undefined
moved require