update tests and fix bug