fixing some bugs to get the tests passing