unit testing and bug fixing