Tests and code for fee calculation functions