Fix context detection

Filter does not always contains a context. Set the context from filter only when it is possible.