fixing broken test and code clean up