Fix some issues and make it testable