A cup of coffee in the evening may be keeping you awake for more reasons than you realise, scientists say.