added function to calculate subttotals. Also added test for subtotal function