Fix tests & various bugs in directive