added tests and improved alignment