Added check_locals and unused_locals functions, and tests.