fix ends and test