some fixes in cmd module and tests

* fix bt if environment empty or absent
* fix tests