Base calculations extracted to external module. Module valid for client and server sides. Added unit test for the module.