Fixing errors and testing