Cleaned Code and Added Simple Tests