add test of empty string
change signature and logic of countMatches method
add comments and light documentation