Remove bashisms for tests
Fix memory leaks (but old lexer related)