Add tests for text lookup, and made text lookup more correct and less broken