Hershey's revenue in the fourth quarter continued the trends it had seen in the previous months but improved margins meant the US chocolate maker was able to beat Wall Street earnings expectations.