optimize proportionalResizeUsingWidth, fix unit tests and some minor bugs