Add tests for benergy functions and fix bugs.