Resolved all superficial race conditions exposed by running the plugin

tests using the `-race` flag.