Fixed and tested prepareContext.