Refactor and test dice

extracted some repeated code, magic numbers, etc.