Fix regex compilation in ContextQuery

A copy-paste error.
Add initial SID query unit tests.