Refactor and fix mink context