Clean up text methods and free errant memory

This commit brings all 3 of the text adding methods inline with each other.
Text encoded is moved into internal  methods and freed when necessary. Tests
are updated to check for missing or bad arguments.