refactor code for exec coming later

Signed-off-by: Victor Vieux <vieux@docker.com>