Should bag of words in training set include test set data when doing text classification?
This is the problem of out of vocabulary (OOV) words.
As a rule the training should not use anything from the test set for several reasons:

The risk of data leakage, which would cause an overestimated performance on the test set.
During training the model cannot use these words to distinguish between classes anyway, since they are not present. So it would be pointless to include them.
In principle the model is meant to be used with any new input text, not only the documents in the current test set. Using the test set words as features in the model actually restricts the model, since it cannot be applied to any other text than the test set.

The correct way to deal with OOV words is either:

To simply ignore them completely, i.e. filter them out before applying the model.
To account for this possibility in the model from the start. Typically this can be done by having a special token UNKNOWN. This option is often combined with filtering out rare words from the training set: every occurrence of a rare words can be replaced by the UNKNOWN token.

The cause of the higher performance when including these features is unclear. I suspect that the inclusion of these features causes the model to be different in a way which happens by chance to have a positive effect on the test set. It's quite unlikely in general, I'm not sure.