fix testing env detection and directory