added tests and simplified them (DRY)