Tests added and bugs are fixed