Add unit tests to back change. Guard invocations against null dereference. Join assertions. Original pull request: #409.