fix most test cases, improve handle on empty filetype