General code update and added more tests