Fixed TokenTerminal and added tests to terminal parsing