Fixed ScopedKeys unit tests (and fixed bug)