fix few bugs with the heartbeat logic
close the write log on exit
move the log channel to WAL and fix the wal tests
fix a test
add a HasAggregates function to SelectQuery
fix compilation errors in the tests