Implemented serialize/deserialize for functions

- Serialize into and deserialize from strings is now possible.

- Added serdes unit tests

- Fixed bug that wasn't removing nil contributing monomials after
  certain operations.