added tests, and fixed stuff that I found was broken through tests