Fix MinSize calculation bug
Fix some unit tests