Add pre and post cmd with functional tests (resolve #1)