Fix problem with TarjanLca implementation

The check for ancestors was inside a loop it ought to have been outside of. Tests updated accordingly.