make CharStream a struct. Add tests.