Add tests and cleanup local

Added tests
and merged in another fork for adding local for some other vars