Added checkoutCompleted and checkoutCancelled logic, updated tests