Move common task functions into a model

Change-Id: If39a70edeaf5736dc84750367678bdb7cbe05506