Fix the overflow in `CircularBuffer::set_capacity`
Fix the overflow in `CircularBuffer::set_capacity`

 - Previously the loop that used to copy the newest elements had a wrong offset.
 - It didn't correctly take into account looping over the `m_head` in the modulo.
 - I refactored the code to have a simplified loop using a proven class method.

Signed-off-by: Konstantin Rebrov <72f3c3f28b3f831246298640b6e3b569c7caf201@intel.com>

geopm/geopm,geopm/geopm,geopm/geopm,geopm/geopm,geopm/geopm