added m2mHistory fields, fixed tests, applied pep8