update alignment functions and add tests