added some unittests
fixed duplicate key exception
implemented all necessary tests