Added context and user middle wares

Also add unit tests and examples.