unit tests and bug fixing