extending existing javascript to make it unit testable, added mock unit test.