tests and minor bug fixes