Creating unit tests and fixing some bugs that came with tests