added preconditions, tweaked tests