charging and discharging implementation and tests