Fixed thread handling
removed obsolete test
fixed locking