code style: fix whitespace

fix whitespace at the end of the line
add newline at the end of the spec file
use extract block refactoring in the spec file