Add serialization utils and fix session bugs.

1. rename and add some serialization helper functions in utils package.
2. fix a bug in memory session provider, which caused by time unit
conversion error, and result in GC problem.