Add test, fixes from test

Inverse dependency wasn't being added if we'd already seen it