Added an energy conversion function and unittests.