added new tests, bug fixing