Investigating the Impact of Connected and Automated Vehicles on Signalized and Unsignalized Intersections Safety in Mixed Traffic