fix scope bug, added directive tests