Fix issues in str.count implementation.

See pull request #343.