Add tests for all basic text objects

Not tested yet:
- seeking
- multi line matches

Includes some refactoring and cleanup.