Fixed most problems, added tests