token dispatcher refactoring + tests