minor refactoring. also added a few test cases and providers