various fixes; rewrote test scripts