cleaned stuff up, added tests