servenv: move some code around

Better reuse on import