Improve testing and code style