improved tests and fixed minor bugs