fixed bugs with serializing and deserializing js code with scope