Added __getstate__ and __setstate__ for pickling
Added pickle tests