Updated error handling in provider code lookup.
Fixed specs to use build for factory test.