Add test cases for alignment directive

Add Angular test cases and refactor directive to set alignment when changed rather than reinitialize the element every time.