Bug fixes for last working tests