Minor refactoring
Added initial tests for contexts and some generic facilities