fix crash on reverse dependency from conn to stm
add tests