Added remaining funds calc and tests