added tests and a small fix for semantic analyser