Fixing tests and code to comply with PEP8 and work on mac.