Add tests and bug fixes for segues