add Util.smart_join and tests