refactoring hsp parsing; fix unit tests