Added unittests, created stubs and fixed bugs