Adding tests, refactored to internal.