Thread safety analysis: minor bugfix to smart pointer handling, and expanded
test case.