Fix for a concurrency issue in StatementContextOwner

Kernel had a single StatementContextOwner instance which was shared among
all threads accessing read-only statement contexts, and yet the
StatementContextOwner didn't consider concurrency.

Added a test case showing the problem as well as a fix in Kernel where a
ThreadLocal<StatementContextOwner> is used instead of a single StatementContextOwner.