ce132b15d5
Motivation: This is small fixes for #10453 PR according @njhill and @normanmaurer conversation. Modification: Simple refactor and takes into account remainder when calculate size. Result: Behavior is correct