Added several tests and modifications