Abstracted calculation to utils, added unit test