Fix tests for linux.
Fix memleak in tests.