Many tests for provider. Fixed some bugs.