Optimize ASCII test-tubes You are given a bunch of ASCII test-tubes, your task is to reduce number of test-tubes used.

Each test tube looks like this:

|  |
|  |
|  |
|~~|
|  |
|  |
|  |
|  |
|__|


Obviously, ~~ is the water level. Test-tube can be also empty, in which case there are no ~~ characters inside. Single tube can contain up to 8 water level units. 

You are given finite number of test tubes with different water levels inside. You have to pour the water in least amount of test-tubes possible, and output the result.

|  | |  | |  | |  |         |~~| |  |
|  | |  | |  | |  |         |  | |  |
|  | |~~| |  | |  |         |  | |  |
|~~| |  | |  | |  |         |  | |~~|
|  | |  | |  | |  | ------&gt; |  | |  |
|  | |  | |  | |  |         |  | |  |
|  | |  | |~~| |  |         |  | |  |
|  | |  | |  | |  |         |  | |  |
|__| |__| |__| |__|         |__| |__|

 05 + 06 + 02 + 00  ------&gt;  08 + 05


As you can see, test-tubes are separated with single space. Empty tubes should not be shown in output.
This is code golf, so code with least number of bytes wins. 

Test cases: http://pastebin.com/BC0C0uii

Happy golfing!
Pyth, 48 45 44 bytes
jCssm+_B,*9\|_X+\_*8;ld\~*9;cUs*L/%2w\~_S8 8

Try it online.
Prints a single trailing space on every line.