major layout fixes; add more unit tests