Split calculation of rects into a separated class and add tests on these new methods.