added more unit tests.
moved test code to common.
decoupled the code from django layer.