add tests for wait directive, move template to directive