Dependency tracker stack not empty after error

This is a fix for #325.

Suggestions for a better, more high-level, black box test are more than welcome.