fix tests, error with BufferedWriter, and query pagination