Encapsulated allocation code

Refactored resize code
Added brief summary at the top
addded duplicate unit test