Use \w+ to detect words and add tests

Fixes  #4.