Read endpoint setting from env variable
Fix tests and clean whitespace