Improve generateToken behaviour.

Fix #26