Added tests for ui directive and fixed bugs found