java imperative chop and tests