various test and bug fixes