Move everything to spec file, small refactoring, mock compatibility