Remove old agent code, since it cause problems with libs
Improve unit tests