Added method to detect unit testing at runtime
Bugfixes