merge upstream changes - unittests and merges with upstream bitcoin