Refactored context to inject database dependency.
Added tests for injection.
Fixed token validation.
Added token test.