Added tests for directive rule handling. Refactored Directive code to
pass tests.