Fix nodemanager unit tests

This commit includes changes ported to the current master from a
private branch.