Refactored and added tests for contexts
Added config field for Environment