I think I've figured out what's wrong. At least the function now works correctly.
I changed this line to:
```javascript
offset += (badMatchTable[haystack[offset + last]] || last+1);
```
and now also single character searches work.