Dimension calculations refactoring + test