Hardware in the Loop Design and Evaluation of Battery Management Algorithms