Fix bugs in TypeScript filter, add simple test