Added unit tests. Code coverage according to EclEmma 80,9%. It may have
problems on a first start because of the threads racing.