Refacted how check digits are calculated and add unit testing for the functionality.