fixed memoryleak
fixed memoryleak
added unittest
added unittest
intermedaiet changes