Fixed calculateWidth(width) function, built more unit tests.