fix #62

After refactoring, TLS variable was accessed from multiple threads =\
added a test